远程共享对象 Fms Flex 4 的问题
我正在尝试开发一个应用程序,同时用户可以在其中进行交互,并且我需要一个持久的远程共享对象,其中包含当前会话中的用户列表。 当新用户进入会话时,他会获得带有列表的服务器对象。该列表应该包含会话中的所有其他用户,但未定义。
我首先这样做:
users_so = SharedObject.getRemote("users_so", nc.uri, true);
users_so.connect( nc );
users_so.addEventListener( SyncEvent.SYNC, usersSyncHandler );
然后将属性设置为共享对象
remoteUsers = new ArrayCollection();
remoteUsers.addItem(displayName);
users_so.setProperty("usersID", remoteUsers);
,最后将用户放入列表中。
谢谢!
I'm trying to develop an application where simultaneous users can interact and i need to have a persistent remote shared object with the list of users currently in session.
When a new user enter in the session he get the server's object with the list. That list was supose to have all the others users in session but is undefined.
I'm doing this first:
users_so = SharedObject.getRemote("users_so", nc.uri, true);
users_so.connect( nc );
users_so.addEventListener( SyncEvent.SYNC, usersSyncHandler );
then i set property to shared object
remoteUsers = new ArrayCollection();
remoteUsers.addItem(displayName);
users_so.setProperty("usersID", remoteUsers);
and finaly i put users in the list.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想说,您需要使用
sharedObject.setDirty("usersID");
SharedObject 无法知道您更改了 ArrayCollection 的内容,因为对它的引用没有更改。您可以使用 setDirty() 强制同步。
我为此使用简单的动态对象。客户端有只读的 SharedObject,服务器决定何时从该 SharedObject 添加/删除客户端。
m_so
是SharedObject
(远程),m_userList
是Object
(本地)I would say, that you need to use
sharedObject.setDirty("usersID");
SharedObject can't know, that you changed content of ArrayCollection, because the reference to it didn't change. You can use setDirty() to force synch.
I am using simple dynamic object for this. Client has read-only SharedObject and server decides when to add/remove client from this SharedObject.
m_so
isSharedObject
(remote),m_userList
isObject
(local)我找到了一种更适合我的解决方案:
它包括调用服务器上的远程函数,然后广播到所有客户端。然后,客户应用必要的更改,使解决方案更加稳定。
I found one solution that works better for me:
It consists in calling remote funcions on server and then broadcast to all clients. The clientes then apply the necessery changes making the solution a lot more stable.