Hi!
This is a piece of ActionScript. I was thinking about posting this
question to an ActionScript forum but I think my problem is due to
differences between FMS and Red5.
The initUsers() function install a onSync handler on the shared object
users_so. initUsers()  is executed in setID. setID is called from Red5
when a client connects to it.
I don't know why the "delete" case will be executed in
users_so.onSync. The flow of execution never arrives to there. I think
it is because the object is deleted and that case signal is not send
by Red5 (Have I to send it explicity?)
Thanks!

function initUsers() {
        users_so = SharedObject.getRemote("users", nc.uri);
        users_so.onSync = function(infoList) {
                trace("onSync called");
                for (var i in infoList) {
                        var info = infoList[i];
                        trace("info.code: "+info.code);
                        switch (info.code) {
                        case "change" :
                                var id = info.name;
                                var mc = _root[id];
                                mc.nameInput.text = users_so.data[id];
                                if (myID != id) {
                                        var ns = new NetStream(nc);
                                        mc.video.attachVideo(ns);
                                        ns.play(id);
                                        mc.ns = ns;
                                }
                                break;
                        case "delete" :
                                var id = info.name;
                                var mc = _root[id];
                                mc.ns.close();
                                mc.nameInput.text = "";
                                mc.video.clear();
                                break;
                        }
                }
        };
        users_so.connect(nc);
}

connectButton.addEventListener("click", this);
function click(ev) {
        var button = ev.target;
        var command = button.label;
        switch (command) {
        case "Connect" :
                nc.connect("rtmp://localhost/helloVideo", userNameInput.text);
                button.label = "Wait...";
                button.enabled = false;
                break;
        case "Disconnect" :
                nc.close();
                button.label = "Connect";
                break;
        }
}

myID = "";
nc = new NetConnection("rtmp://localhost/helloVideo");

nc.onStatus = function(info) {
        connectButton.label = "Connect";
        connectButton.enabled = true;
        switch (info.code) {
        case "NetConnection.Connect.Success" :
                connectButton.label = "Disconnect";
                statusInput.text = "Online";
                break;
        case "NetConnection.Connect.Failed" :
                statusInput.text = "Cannot reach server. Possible network 
error.";
                break;
        case "NetConnection.Connect.Rejected" :
                statusInput.text = info.application.msg;
                break;
        case "NetConnection.Connect.Closed" :
                statusInput.text += " Connection closed.";
                break;
        }
};

nc.setID = function(id) {
        myID = id;
        statusInput.text = "Online. Your client's ID is: "+myID;
        ns = new NetStream(nc);
        ns.attachAudio(Microphone.get());
        var cam = Camera.get();
        ns.attachVideo(cam);
        ns.publish(id);
        _root[id].video.attachVideo(cam);
        initUsers();
};

_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org

Reply via email to