Hi guys,

I'm trying to keep track of who is joining and leaving, so I tought about two functions for my app, "addUser" , "removeUser"...
I'm lost in my Application.java .. to broadcast those events to who is connected. if someone can help, the code follows.
btw, I'm using Red5's appLeave event for disconnection cuz was the only who seems to work now, i'm using trunk
How I don't know java I just pasted the newstream event cuz it looked more like what I need..heheh but don't work...


    public boolean appJoin(IClient client, IScope scope) {
        log.info("Client joined app " + client.getId());
        // If you need the connecion object you can access it via.
    //    IConnection conn = Red5.getConnectionLocal();
        Iterator<IConnection> it = scope.getConnections();
       
        while (it.hasNext()) {
            IConnection conn = it.next();
//            if (conn.equals(current)) {
//                // Don't notify current client
//                continue;
//            }

            if (conn instanceof IServiceCapableConnection) {
                IServiceCapableConnection service = (IServiceCapableConnection) conn;
                service.invoke("addId",
                        new Object[] { conn.getClient().getId() }, this);
                if (log.isDebugEnabled()) {
                    log.debug("sending notification to " + conn);
                }
            }
        }
        return true;
    }


   
 
   
    public void appLeave(IClient client, IScope scope){
       
    //    IServiceCapableConnection service = (IServiceCapableConnection) conn;
        log.info("Client DISjoined app " + client.getId());
        IConnection current = Red5.getConnectionLocal();
        Iterator<IConnection> it = scope.getConnections();
        while (it.hasNext ()) {
            IConnection conn = it.next();
            if (conn.equals(current)) {
                // Don't notify current client
                continue;
            }

            if (conn instanceof IServiceCapableConnection) {
                ((IServiceCapableConnection) conn).invoke("removeId",
                        new Object[] { conn.getClient().getId() }, this);
                if (log.isDebugEnabled()) {
                    log.debug("sending notification to " + conn);
                }
            }
        }
   


--
. m a r c o s    a u g u s t o  ;

.e onde houver fé, que eu leve a dúvida.
_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org

Reply via email to