actionscript-3flash-media-servershared-objects

Remote shared object not firing onSync method after update


I have game server, FMS 4.5 on Windows, already working prefect, and client apps were created in old CS4, and all is perfect.

Now I want to create a mobile app in AS3, and have a problem with remote shared object, which is working perfect in old flash program.

When users are logged into app, I'm receiving an update with onSync method. But whenever remote shared object is updated, I'm not receiving updates.

for example, on client, where I have main_nc as netConnection object:

var ncu_so:SharedObject = SharedObject.getRemote("Zusers", main_nc.uri, false);
ncu_so.addEventListener(SyncEvent.SYNC, syncNCU);
ncu_so.client=this;
ncu_so.connect(main_nc);

private function syncNCU(e:SyncEvent):void {
    ........
    //here I receive new info....
}

and sample on server...

application.onAppStart = function(){
    this.Zusers_so = SharedObject.get( "Zusers", false );
    ...........
}
function sampleUserEnter(client) {
    var t=new Object();
    t.username=client.username;
    application.Zusers_so.setProperty(client.id,t);
    //this one call is synced with app
}
function sampleChangeName(client,newName) {
    var t=application.Zusers_so.getProperty(client.id);
    t.username=newName;
    application.Zusers_so.setProperty(client.id,t);
    //this IS NOT syncing with app
}

As I said, this code is working with old flash software, but wont update when using AS3. Any idea?


Solution

  • I found an easy solution. Not sure why it works but it works....

    var ncu_so:SharedObject = SharedObject.getRemote("Zusers", main_nc.uri, false);
    ncu_so.addEventListener(SyncEvent.SYNC, syncNCU);
    //I add the listener for checking status
    ncu_so.addEventListener(NetStatusEvent.NET_STATUS, statusNCU);
    ncu_so.client=this;
    ncu_so.connect(main_nc);
    
    private function syncNCU(e:SyncEvent):void {
        ........
        //here I receive new info....
    }
    //In function for NetStatus event, I just set a simple property
    //which I do not use in the app..
    //and sunchronization start working as usual after initial sync
    private function statusNCU(ev:NetStatusEvent):void {
        if (ev.info.code == "NetConnection.Connect.Success") {
            ncu_so.setProperty("anyPropertyName",new Date());
        }
    }