I'm trying to use the SharedObject part of AFCS and running into some issues. I've created a SharedObject based on a property in the application. When the property changes I set the SharedObject to the new value. My goal is to be able to compare values with everyone on the system so I've set up a bunch of event handlers to see when properties are added or changed so I can see if any of them match my value. But when I debug the application in Flash Builder the added/changed properties don't ever fire when I change it as another user in the room. Here's the code:
protected function cSession_synchronizationChangeHandler(event:SessionEvent):void
{
if( event.type == SessionEvent.SYNCHRONIZATION_CHANGE )
{
var config:NodeConfiguration = new NodeConfiguration();
config.modifyAnyItem = false;
config.userDependentItems = true;
sharedColor = new com.adobe.rtc.sharedModel.SharedObject();
sharedColor.nodeName = cSession.userManager.myUserID + "_color";
sharedColor.sharedID = "color";
sharedColor.setNodeConfiguration(config);
sharedColor.subscribe();
sharedColor.addEventListener(SharedObjectEvent.PROPERTY_ADD, onPropertyAdd);
sharedColor.addEventListener(SharedObjectEvent.PROPERTY_CHANGE, onPropertyChange);
}
}
protected function onPropertyAdd(event:SharedObjectEvent):void
{
trace('test');
}
protected function onPropertyChange(event:SharedObjectEvent):void
{
trace('test');}
Shouldn't those onPropertyAdd and onPropertyChange functions fire when another user in the room adds or changes something? What am I doing wrong?
Thanks in advance.
=Ryan
ryan@adobe.com
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Ryan,
Changing this line from
sharedColor.nodeName = cSession.userManager.myUserID + "_color";
to
sharedColor.nodeName = "a static & unmutating variable" + "_color";
// or justsharedColor.nodeName = "_color"
will fix the issue.
What was happening is that, each user was creating his own node and updating items within the node. So each user was practically in his own world. Others users were not recieving the updates as they themselves were listening to the sharedObject events within their node.
Thanks
Arun
Views
Replies
Total Likes
Hi Ryan,
Changing this line from
sharedColor.nodeName = cSession.userManager.myUserID + "_color";
to
sharedColor.nodeName = "a static & unmutating variable" + "_color";
// or justsharedColor.nodeName = "_color"
will fix the issue.
What was happening is that, each user was creating his own node and updating items within the node. So each user was practically in his own world. Others users were not recieving the updates as they themselves were listening to the sharedObject events within their node.
Thanks
Arun
Views
Replies
Total Likes
In fact, in general, it's not necessary to supply a nodeName for a Shared Model class - this can be useful if you have several SharedObjects residing on one CollectionNode (as you, inadvertently I think, created), but for a case where everyone should be listening to one sharedObject, there's no real need to have them specify one (the SharedObject will make one up for you).
nigel
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies