Skip to main content
April 8, 2011
Question

FMS Remote SharedObject not Always Updated?

  • April 8, 2011
  • 2 replies
  • 2549 views

I'm somewhat new to FMS. We're creating a chat application and using s remote SharedObject to keep everyone in sync about who is in the room.

But despite the fact that I use the following:

_sharedObject.setProperty("groupList", groupList);
_sharedObject.setDirty("groupList");  

to force the shared object to update the list of who's in the room, for some reason it does not always update correctly when someone enters the room and adds themselves to the shared object.

The problem seems to be that the SyncEvent.SYNC event does not always get sent all the time.

More troubling it that if the user closes the browser window or navigates to another page, NetStatusEvent NetGroup.Neighbor.Disconnect and NetGroup.MulticastStream.UnpublishNotify are not reliable to use to remove user's from the list.

My assumption is that remote shared objects are just not that reliable in some cases. Should I use server side scripts to keep track of users and what groups they are in?

Thanks in advance.

    This topic has been closed for replies.

    2 replies

    Participant
    May 16, 2011

    I am having issues with shared objects and SYNC Events as well.  The setProperty function updates my SO.data but as soon as the SYNC event triggers, my SO.data is wiped if its non-persistent or reverts to the initial value if its a persistent SO.

    here is my code:

    private function onConnect():void{

         so = SharedObject.getRemote(theObj.cID, nc.uri, false);

         so.connect( nc );

         so.addEventListener(SyncEvent.SYNC, usersSyncHandler );

         so.setProperty( theObj.tID, nc.nearID);

         so.setDirty( theObj.tID );

        trace("Current so.data "+theObj.tID+" : "+so.data[theObj.tID]);

         myPeerID = nc.nearID;

         ng = new NetGroup(nc, gs.groupspecWithAuthorizations());

         ng.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

    }

    private function usersSyncHandler( event: SyncEvent ): void{

         trace("Current so.data "+theObj.tID+" : "+so.data[theObj.tID]);

    }

    results:

    Current so.data T000001 : 182348e3852345v42204853456788963de21c94cfa5984567bd2f4d4d1c87853h

    Current so.data T000001 : undefined

    Participating Frequently
    April 9, 2011

    It's best to have changes to the SharedObject on the server side instead of the client side.  Disconnects are detected on the server and you can call a function that will then remove that user from the user list.  If you update via the client and two updates happen about the same time then the updates won't be in sync.

    April 10, 2011

    Excellent, thanks very much for your response.

    Now I wonder how I can avoid collisions if I change the SharedObject on the server side.

    Should I have the client call the server method passing it a timestamp, which will allow me to queue the changes to the shared object? Should I then inspect that queue to remove redundant changes? Just wondering how I can avoid collisions and error prone changes.

    Participating Frequently
    April 11, 2011

    You can have the logic to remove the client name from shared object in application.onDisconnect().

    This function is called on server side whenever a client connected to the perticular application disconnects from the application.