Thought Cloud UI #3: Synchronization status

The Thought Cloud demo is on GitHub. Fork it and follow along.

We just got an application limping along. It hard-codes the user, and it displays a list of clouds. We can see that isolated storage is working for us, because we can close the application and our clouds don’t disappear. But how do we know if the communication strategy is working?

You can report the status of the communications directly to your user through data binding. Community has two properties designed for this:

  • Synchronizing
  • LastException

These two properties are Independent, so you can data bind them through any view model. Let’s add these to the MainViewModel.

public bool Synchronizing
{
    get { return _community.Synchronizing; }
}

public bool HasError
{
    get { return _community.LastException != null; }
}

public string LastError
{
    get
    {
        return _community.LastException == null
            ? null
            : _community.LastException.Message;
    }
}

Then we can data bind these properties to some controls. The busy indicator will be visible when Synchronizing is true. The error indicator will be visible when HasError is true. And the text of the error indicator will be the LastError string. To help us convert boolean to Visibility, let’s add a reference to Itzben. It contains a useful little VisibleWhenTrueConverter. Itzben is available on NuGet.

image

When we run the app, we see a problem. The error message says: “Domain <<Your API key>> not registered.” We have to use a real Correspondence API key. If you want to use my Correspondence server, please email or mention me for a key. I am letting people use the server free for a limited time.

public class POXConfigurationProvider : IPOXConfigurationProvider
{
    public POXConfiguration Configuration
    {
        get
        {
            string address = "https://api.facetedworlds.com:9443/correspondence_server_web/pox";
            string apiKey = "B22E33EB0ABD46FE9161BF4FB8748A65";
            return new POXConfiguration(address, "FacetedWorlds.ThoughtCloud", apiKey);
        }
    }
}

Once we put the real API key in place, the service works. It sends new clouds to the server. If you run the application on a different machine, it will pull those clouds back down from the server.

Leave a Reply

You must be logged in to post a comment.