I’ve been playing with a little WPF desktop application that creates “notes” using the Live Framework SDK on Live Mesh. It’s intentionally simple and it looks like this;
and the notes are the little TextBoxes over in the ListBox on the right hand side. There are buttons (top left from top to bottom) to;
- Connect to the Local/Cloud Live Operating Environment (LOE)
- Create a MeshObject and DataFeed. The application stores all the notes on a single DataFeed inside a single MeshObject and it is this button that creates these. It’s really only intended to be used once as a “setup” operation. There’s no option in the application to invite any user to share the MeshObject although I’ve written a little about that elsewhere (here and here and here and here).
- Connect the application to the DataFeed and MeshObject that are already created.
- Delete everything so that I can start again (note – the application needs shutting down after pressing this button).
So the first time I run it I would do perhaps (1) and then (2) and then wait a few minutes, run it again and then do (1) and then (3).
Then over on the right-hand-side there’s a button to add a note and one to remove a note and the text of a note can also be changed by clicking on it and typing something else and then hitting TAB.
I ran through the setup step of launching the application, connecting to the local LOE and then clicking the “Create…” button to create my initial objects.
With that in place, I can run two copies of the application as below and connect one to my Local LOE and another to the Cloud LOE;
then I can add some notes on the Cloud LOE and see them sync to the local LOE;
( it looks like I should have sorted them in some fashion 🙂 ).
This is just a much simpler version of the photo sharing application that I was experimenting with back here but it’s different in a couple of ways in that the previous application looked at a DataFeed and only really looked at its DataEntries collection whereas this application is also trying to keep an eye on the SyncEntries collection and the NewsItems collection as well.
To try and illustrate why you’d bother with that, it’s interesting to see what happens if I delete note “Two” in the picture above on the Cloud window on the right hand side.
Using the “Live Framework Resource Browser”, I can have a look into my MeshObjects on the local LOE and I see both DataEntries and FeedSync;
Exploring the DataEntries;
the “problem” here is that the DataEntries collection looks to only report the data as it currently is and gives me no historical view as to how the data came to be in that particular state. Exploring the FeedSync feed though is much more interesting in that it shows me 3 entries including this one;
so what the FeedSync feed is letting me know is that there has been another entry here in the past and it’s been deleted. That can be useful if ( as was the case in my example ) one application was displaying a piece of data when another application came along and deleted it. Right now, my notes application displays this;
and it’s doing that by reaching through the DataFeed.SyncEntries collection looking for items that have marked themselves as deleted with a LINQ query.
A related scenario is one where two users are working on shared data and User1 runs up the application after a little while and finds a whole bunch of changes that User2 has made in the meantime. User1 might want to know what’s been going on with the shared data and my test application here uses the DataFeed.NewsItems to log NewsItems as/when changes are made in the application. That is, there’s another piece of UI here showing NewsItems;
and via that collection of NewsItems the user can get to see what’s been going on with their data throughout the lifetime of the application.
Another related scenario is one where one user edits a piece of data whilst another user is working on the same thing. For example, given the two running applications below;
if I quickly;
- Change the text for the note labelled “Three” on the right to “Change1”
- Change the text for the note labelled “Three” on the left to “Change2”
then I can force a problem with concurrent updates.
Using the “Live Framework Resource Browser” again, the DataEntries on my DataFeed give no indication of this problem;
in that it is displaying the content of my DataEntry as simply being “Change 1” but I know that one client changed the value to “Change 2”.
If I look into the FeedSync feed then I can see;
so it’s showing that there is a conflict that needs resolving for this particular item rather than just an accepted value of “Change 1”.
In my application, I try and offer a little UI ( pretty basic at the moment ) around this in that it displays;
and that lets me go with either the value that “won” the conflict or the value that “lost” the conflict.
I’ll try and turn this stuff around into some videos for Channel9 but, in the meantime, I’ve uploaded the application project here for download ( note that you’ll have to embed some credentials in the application to get it to compile ).