red5服务器端共享对象

发布于 2024-08-12 00:28:45 字数 978 浏览 4 评论 0原文

我试图将所有用户存储在服务器端创建的共享对象中,因此所有用户都会获得所有在线用户的同步列表。

我认为我在服务器端正确创建了共享对象,但我无法在 Flash 应用程序中“找到”共享对象。

在 Java Red5 Application 类内部:

ISharedObject userList; 

public boolean connect(IConnection conn, IScope scope, Object[] params) 
{     
    if(userList == null)
    {
        createSharedObject(scope, "userList", false);
        userList = getSharedObject(scope, "userList");
    }

    userList.setAttribute( "user", "some name" );

    return true;
}

Flash 共享对象如下所示:

private var _userSO:SharedObject;

private function initUserSO() // I call this function when I get a netConnection
{
    _userSO = SharedObject.getRemote("userList", this.uri, false); 
    _userSO.addEventListener(SyncEvent.SYNC,syncUsers);
    _userSO.connect(this); // this = netconnection
}

private function syncUsers(e:SyncEvent):void
{
    MonsterDebugger.trace('userManager',_userSO.data);
}

但 _userSO 似乎在服务器上找不到共享对象。

I'm trying to store all the users inside a sharedObject thats created on the server-side, so all the users get a synchronized list of all the online users.

I think I create the sharedObject correct on the server-side but I cant "find" the sharedObject in the flash application.

Inside the Java Red5 Application class:

ISharedObject userList; 

public boolean connect(IConnection conn, IScope scope, Object[] params) 
{     
    if(userList == null)
    {
        createSharedObject(scope, "userList", false);
        userList = getSharedObject(scope, "userList");
    }

    userList.setAttribute( "user", "some name" );

    return true;
}

The Flash sharedObject looks like this:

private var _userSO:SharedObject;

private function initUserSO() // I call this function when I get a netConnection
{
    _userSO = SharedObject.getRemote("userList", this.uri, false); 
    _userSO.addEventListener(SyncEvent.SYNC,syncUsers);
    _userSO.connect(this); // this = netconnection
}

private function syncUsers(e:SyncEvent):void
{
    MonsterDebugger.trace('userManager',_userSO.data);
}

But the _userSO doesn't seem to find the sharedObject on the server.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见终念 2024-08-19 00:28:45

我发现您可以使用下面的行来执行 as3 脚本,而不是将数据存储在共享对象中:

ServiceUtils.invokeOnAllConnections(room, "my_as3_function", userList);

I found out that you could use the below line to execute as3 script instead of storing the data inside a sharedObject:

ServiceUtils.invokeOnAllConnections(room, "my_as3_function", userList);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文