[Verse-dev] versifying non-verse native apps

eskil at obsession.se eskil at obsession.se
Tue Feb 28 16:50:24 CET 2006


Hi

In some what late response to Brechts questions about how to integrate non verse
apps with verse ill try to give some ideas about ho i think it should be
implemented.

If you have app that stores data in its own data format, you will probably need
to have a separate buffer storing the data in verse format too. The verse data
set can only be modified by verse.

So the first thing you need to do is to write two synchronization algorithms.
One that changes the apps data so that it matches the verse data and one that
sends commands to verse to make the verse buffer match the data in the app.

now the question is when do you call thees sync functions. If the app stays
inactive, meaning the user isn't changing the data in any way, any change to
the verse data set should automatically result in the app data being updated
from the verse data.

If the user starts modifying the data you stop synchronizing verse-to-app and
start synchronizing app to verse. so at this moment the app no longer reacts to
any incoming commands form verse, but they can however stored in the verse
buffer (more about that later).

Then whenever the user stops editing you need to switch back to verse-to-app
mode, bu you cant do that immediately, you need to wait until all commands has
gotten back to you for the host. if you don't you will first synchronize with
the old data and then later the new one, so form the users point of view it
will look stranger. There a few different ways of doing this. The easiest way
is to just set a timer of a few seconds. You can also count the number of
commands you get back form the server and compare them with the number of
commands you sent. in this case you need to have a time out anyway, things may
be collapsed, or rejected by the server. This works best for changes where you
make just one set of change not continuous changes like dragging vertices. An
other way is to have a timeout when the the traffic stops coming in, this also
requires a second time out if the traffic doesn't stop coming in with in
reasonable time.

So when we talk about how the data can move in two directions verse-to-app and
app-to-verse you shouldn't have one switch for the entire app, you can have one
switch per node or even layer. So while you are editing one node and it is in
app-to-verse mode an other node may be in verse-to-app mode so the you can see
how some one else is editing it.

Getting back to synchronization, it can work a bit differently depending on the
type of app you are working with. syncing verse to app shouldn't be a problem
at all, but app to verse is a little bit more complicated. The problem is that
while you are in that mode things that come from the verse server may get
trashed. if some one say adds a vertex, while you are in sync mode, the sync
algorithm may say "this vertex shouldn't be here" and then remove it.

The best thing is if you don't update the verse data while you are syncing
app-to-verse. this works very well if the operation you are preforming is
instantaneous. you make a change and then its done. in this case you can just
synchronize once then do callback update a few times and then you are back in
verse-to-app mode.

But with continuous changes things may get lost. The best way to solve this
problem is to only switches as little data as possible in to app-to verse mode.
you can do more complicated things if you know a little bit about what the
change in the app is. for instance if you know the function you apply only move
vertices, you can tell the synchronization not to do anything but move vertices.
so any create/destroy vertices or polygon wont be affected. This type of code
will easily be complicated and i would advice not to try to implement it until
the basics work well.

Cheers

E


More information about the Verse-dev mailing list