rso between flex and red5. I can create but cant read

落爺英雄遲暮 提交于 2019-12-12 01:46:30

问题


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.

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.

there is my code on the client side:

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");
            }

on the server side i have:

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;
    }

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


回答1:


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.



来源:https://stackoverflow.com/questions/7620526/rso-between-flex-and-red5-i-can-create-but-cant-read

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!