flex 和 red5 之间的 rso.我可以创建但不能阅读

人气:964 发布:2022-10-16 标签: red5 shared-objects apache-flex

问题描述

所以我仍然坚持这一点,我可以创建远程共享对象,但在我通知更改时无法读取.我使用的是 red5 的主干版本,以及带有 Flash Builder 的 flex 4.0.在调试中,我可以看到 changeLog 具有 rso 更改值的名称,但对象本身具有未定义的值.

so im still stuck on this that i can create remote shared object but cant read while im notified about changes. im using trunk version of red5, and flex 4.0 with flash builder. in debug i can see that changeLog has name of the changed value of rso, but object itself has undefined value.

目前我在本地 Windows 机器上工作,但在 ubuntu 服务器 10.04 上尝试了所有方法并得到相同的结果.我可以连接到房间,创建一个共享对象,所有客户端都会收到通知,但只有更改 rso 值的用户才能读取一次该值,其他人只会获得未定义的值.有没有人有这个问题的经验?我真的很感激任何帮助,因为这让我发疯,我大约三个星期,阅读所有关于 rso 的教程,但无法获得任何解决方案.我尝试了持久性和非持久性,由服务器和客户端发起,但一直得到相同的结果.

Currently im working on local windows machine, but tried everything on ubuntu server 10.04 and got the same results. i can connect to the room, create a shared object and all client are notified about that, but only the user who changed the value of rso can read the value that one time, other just get undefined value. Does anybody has any experience with this issue? I would really appreciate any help, because this is just driving me crazy, im for about three weeks, read all tutorials about rso and cant get any solution. I tried with persistent and non-persistent, initiated by server and by client, but all the time get the same results.

客户端有我的代码:

protected function application1_creationCompleteHandler(event:FlexEvent):void {
                var room_id:Number = vars("room");
                connection = new NetConnection();
                connection.connect("rtmp://127.0.0.1/video/" + room_id);
                connection.addEventListener(NetStatusEvent.NET_STATUS, onConnected);
                connection.client = this;
            }

private function onConnected(event:NetStatusEvent) : void {
                if(event.info.code == "NetConnection.Connect.Success") {

                    so = SharedObject.getRemote("video", connection.uri, true);
                    so.addEventListener(SyncEvent.SYNC, onSync);
                    so.connect(connection);


                } else {
                    Alert.show("Unsuccessful Connection", "Information");
                }
private function onSync(event:SyncEvent):void {
          if(so.data["video"] != undefined)
             Alert.show(so.data["video"].toString(), "Information");
            }

在服务器端我有:

ISharedObject so;
    IServiceCapableConnection iconn;
    public static IScope iroom;

    /** {@inheritDoc} */
    @Override
    public boolean connect(IConnection conn, IScope scope, Object[] params) {

        iconn = (IServiceCapableConnection)conn;

        if (!super.connect(conn, scope, params)) {
            return false;
        }

        System.out.println("Connected True");

        return true;
    }

    /** {@inheritDoc} */
    @Override
    public void disconnect(IConnection conn, IScope scope) {
        super.disconnect(conn, scope);
    }
 @Override
    public boolean roomStart(IScope room) {
        if (!super.roomStart(room))
            return false;
        createSharedObject(room, "video", true);
        so = getSharedObject(room, "video");
        System.out.println("Room created succesfully");
        ISharedObjectListener listener = new SOEventListener();
        so.addSharedObjectListener(listener);

        return true;
    }

在客户端使用侦听器时,我无法在控制台中输出并查看 rso 已更改以及当前值是多少,尽管我正在检查 red5 服务器上的持久性 rso 文件,看起来一切正常,唯一的事情是什么缺少为所有客户读取价值的机会.我将不胜感激任何帮助.谢谢

with listener on the client side i cant make output in console and see that rso is changed and what is current value, although im checking the persistence rso file on red5 server and the that look like everything is working and the only thing what is missing is opportunity to read value for all clients. I will appreciate any help. Thanks

推荐答案

大问题看起来不是那么大.问题在于编码,因为 AS3 和我需要做的所有事情,默认情况下是 AMF3,只需将编码更改为 AMF0.

big problem appears not such a big. Problem was with encoding, which is AMF3 by default since AS3 and all i need to do, just change the encoding to AMF0.

connection = new NetConnection();
connection.objectEncoding = ObjectEncoding.AMF0;
connection.connect("rtmp://127.0.0.1/video/" + room_id);

希望对任何人都有帮助,因为不知何故,网上关于此类事情的信息并不多.

Hope that helps for anybody, because somehow there is not a lot information about things like these on the net.

230