OData SyncClient for MIX

OData SyncClient for MIX

Yesterday Charlie Kindel tweeted about this session planner that can be used for MIX. What’s really interesting about this Silverlight application is that it has the ability to synchronise data and work offline.

image

Having noticed this (which you can hardly miss given the “Sync” icon in the top right corner) I wondered if there was a session on Sync.  Sure enough there is a session called “Building Offline Web Apps Using Microsoft Sync Framework” with the following abstract:

Come learn about offline web applications and how they can provide a better experience to your users.  Windows Azure, Microsoft SQL Azure, and Sync Framework are the core technologies that enable web developers to create offlien applications. See how to use these three technologies to produce great applications.  We also introduce our upcoming support for offline Microsoft Silverlight clients and show you how you will have the flexibility to use any platform for your offline applications, device or desktop.

Coming from “mobile-land” where we take doing synchronisation (whether it be DIY webservices, RDA, Merge, Sync Services) for granted the idea that finally web developers might get the concept of offline applications is quite laughable. But, leaving that aside what interested me is what this “upcoming support for Silverlight” is going to be – well they kind of let the cat out of the bag with the session builder. Whilst there is a pseudo attempt at hiding what’s going on in the sync (I’m guessing more out of privacy concerns rather than hiding the sync technology) this is easily broken using Fiddler (you’ll have to enable https tracing in Fiddler and add the Fiddler certificate to your trusted cert list – see http://www.fiddler2.com/Fiddler/help/httpsdecryption.asp for instructions).

A typical sync session looks like this:

image

Notice that each request to either GetChanges or UploadChanges has the same suffix:

/ODataSync.svc/GetChanges/377d1869-e69a-4b67-9ddd-392169e9b06e?userToken=d39ea0f0e5104c4aad457b897a7b4b62

/ODataSync.svc/UploadChanges/377d1869-e69a-4b67-9ddd-392169e9b06e?userToken=d39ea0f0e5104c4aad457b897a7b4b62

The response to the first GetChanges call (which doesn’t contain any data) looks something like:

image

In this we can see that there is an anchor and then there are a list of entries.  Each entry, under the content node, contains a series of properties.  As you can see sync is using odata to transport entity information.

Each successive GetChanges call sends the anchor back to the server – I’m guessing this anchor value is used to track the synchronization state of the client with the server.

“eyJLbm93bGVkZ2VCbG9iIjoiQUFBQUJRQUFBQUFBQUFBQkFBQUFBQUFBQUFVQUFCQUFBQUFDTjMwWWFlYWFTMmVkM1RraGFlbXdidGxzQU1rZkowNyt1MHNWYXE1YVBDNEFBQUFZQUFBUUFTZ0NBQUFCQUFBQUZRQUFBQUVBQUFBQkFBQUFBQUFBQUJjQUFBQUJBQUFBRmdBQUFBRUFBd0FBQUFBQUFBQUFBQUFBQUJrQkFBQUFBQT09IiwiVGFibGVXYXRlcm1hcmtzIjpbeyJLZXkiOiJTY2hlZHVsZUl0ZW0iLCJWYWx1ZSI6MTcwNTZ9XX0=”

Of course, the session planner must be storing data in Silverlight’s isolated storage.  After a little poking I managed to find some of the data being stored:

{"Anchor":"eyJLbm93bGVkZ2VCbG9iIjoiQUFBQUJRQUFBQUFBQUFBQkFBQUFBQUFBQUFVQUFCQUFBQUFDTjMwWWFlYWFTMmVkM1RraGFlbXdidGxzQU1rZkowNyt1MHNWYXE1YVBDNEFBQUFZQUFBUUFTZ0NBQUFCQUFBQUZRQUFBQUlBQUFBQkFBQUFBQUFBQUFFQUFBQUNBQUFBQUFBQUFBQUFBRWswQUFBQUFRQUFBQUFBQUVrekFBQUFGd0FBQUFFQUFBQVdBQUFBQVFBREFBQUFBQUVBQUFBQUFBQUFHUUVBQUFBQSIsIlRhYmxlV2F0ZXJtYXJrcyI6W119","Data":[{"Key":"speaker","Value":[{"__type":"ItemChangeOfDbSpeakerzgKIiSuC:#Microsoft.Synchronization.Offline","IsCreate":false,"IsDirty":false,"IsTombstone":false,"Item":{"Bio":"Beginning life as an art student, then after a stint in the military joining the world of technology, Adam Kinney feels right at home in that sweet spot between Designer and Developer. Always at least a part-time evangelist, Adam has traveled the trail of UI technologies. First HTML/CSS, then Flash, WPF and now Silverlight, the one client technology to rule them all, he has enjoyed learning, experimenting and teaching them all.rnAdam’s current focus is Expression Blend, the first interactive design tool that’s really made him happy as a designer and developer.","SpeakerDisplayName":"Adam Kinney","SpeakerFirstName":"Adam","SpeakerID":"b5056969-1f9f-4268-8cbd-64a2fcb7080f","SpeakerLastName":"Kinney","SpeakerName":"Adam-Kinney"}},{"__type":"ItemChangeOfDbSpeakerzgKIiSuC:#Microsoft.Synchronization.Offline","IsCreate":false,"IsDirty":false,"IsTombstone":false,"Item":{"Bio":"","SpeakerDisplayName":"Akash Patel","SpeakerFirstName":"Akash","SpeakerID":"cd381f2f-cdca-469a-a937-dae1ad6f72d6","SpeakerLastName":"Patel","SpeakerName":"Akash-Patel"}},

Sure enough as you can see the anchor is being persisted, along with a series of entities. There are typical fields that you’d expect with synchronization such as IsCreate, IsDirty, IsTombstone but very little in the way of date time or versioning stamps. This again points towards the server doing the bulk of the synchronization logic.

Well that’s enough poking around with the session builder for one day – I can’t wait to see this session at MIX and see what the sync team have been working on.

Leave a Reply

Your email address will not be published. Required fields are marked *