Hello AFCS team,
I have some questions regarding the strategy of sharing shapes,
how SharedWBModel does it and the possibly wrong way i may be following.
I see that SharedWBModel has a two Steps add shape handling events:
/**
* Dispatched when the shape is first created
*/
[Event(name="shapeCreate", type="com.adobe.events.WBModelEvent")]
/**
* Dispatched when the shape is added
*/
[Event(name="shapeAdd", type="com.adobe.events.WBModelEvent")]
How are they exactly used to sync shapes between users ?
You also have a _seenIDs and _addedShapes,used in the following onItemReceived case
if (p_evt.nodeName==SHAPE_DEFINITION_NODE && _seenIDs[shapeDesc.shapeID] == null)
// it's a totally new shape
onShapeCreate(shapeDesc, didIChangeIt);
} else if (p_evt.nodeName==SHAPE_DEFINITION_NODE && _addedShapes[shapeDesc.shapeID]==null) {
// we'd seen the shape, but not added it
onShapeAdd(shapeDesc, didIChangeIt);
To summarize my question
What messages are sent between Users Alice and Bob When Alice adds a Shape and why do we have Two steps create and add.
In my case, i used two types of Nodes: ADD_SHAPE and PROP_UPDATE_SHAPE with STORAGE_SCHEME_MANUAL.
- When Alice adds a shape on her Canvas, the shape ID is set to 1 (id++) and i call publishItem add_shape with a shape definition and a unique id: ID (1)
- Bob receives the message look at the shape definition set the shape id to what it was sent with (1), increments his own internal Shapes counter to +1 and add the Shape to his Canvas.
- Now Bob adds a new Shape on his Canvas, his internal shape id count is at 1 so he adds 1 to get ID: 2 and calls publishItem add_shape..
- Alice receives it and so on.
Updates of shapes works in a similar way except ids match existing shapes.
Now this technique works quite well but very rarely i can see some out of sync shapes like "the square on Alice canvas" is actually "the circle on Bob canvas"
I think that comes from the following case:
Alice creates Shape S and publish (id=1)
At the same time Bob creates Shapes S2 ans publish item with (id=1) as well.
Bob receives Alice message and add S to his canvas with shape id 1, the same id as the S2 he just sent.
They both have shapes with id 1which are not the actually same shape S != S2.
The solution may be to check that the id of the ADD_SHAPE message is equal to the internal counter ?.
How does SharedWBModel handles these cases, is that why shapeCreate and shapeAdd are used for.
How would you solve such a case ?
Thank you for your advices.
Greg
Views
Replies
Total Likes