更新后远程共享对象不触发 onSync 方法
Remote shared object not firing onSync method after update
我有游戏服务器,Windows 上的 FMS 4.5,已经运行完美,客户端应用程序是在旧的 CS4 中创建的,一切都很完美。
现在我想在 AS3 中创建一个移动应用程序,但是远程共享对象有问题,它在旧的 flash 程序中运行得很好。
当用户登录到应用程序时,我正在使用 onSync 方法接收更新。但是每当更新远程共享对象时,我都收不到更新。
例如,在客户端上,我将 main_nc 作为 netConnection 对象:
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....
}
并在服务器上采样...
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
}
正如我所说,此代码适用于旧的闪存软件,但在使用 AS3 时不会更新。有什么想法吗?
我找到了一个简单的解决方案。不知道为什么它有效但它有效....
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());
}
}
我有游戏服务器,Windows 上的 FMS 4.5,已经运行完美,客户端应用程序是在旧的 CS4 中创建的,一切都很完美。
现在我想在 AS3 中创建一个移动应用程序,但是远程共享对象有问题,它在旧的 flash 程序中运行得很好。
当用户登录到应用程序时,我正在使用 onSync 方法接收更新。但是每当更新远程共享对象时,我都收不到更新。
例如,在客户端上,我将 main_nc 作为 netConnection 对象:
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....
}
并在服务器上采样...
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
}
正如我所说,此代码适用于旧的闪存软件,但在使用 AS3 时不会更新。有什么想法吗?
我找到了一个简单的解决方案。不知道为什么它有效但它有效....
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());
}
}