I've started playing around with Red5.

By the way, this is my first java application so please be tender.

What I want to do is to build a simple chat room, with private chat 
(maybe video?)

The first doubt I got is:

Which one is the main difference between these methods?

appStart
appConnect
connect

appDisconnect
disconnect

What I saw in red5 log files is that the first method called is 
"Connect", then comes "appConnect", but I never saw "appStart" (maybe 
not logged)

Second, I've read about creating a new instance of the application to 
make a chat room, at least that's what I got, For example, I have an 
application rtmp://localhost/chat, to make more rooms I
need to create another instance under rtmp://localhost/chat/myRoom, 
rtmp://localhost/chat/myOtherRoom, and so on?

And last but no least,

I'm trying to manage users in rooms without using Flash SharedObjects, 
but inside the Java Application.

I do as follows:


private Vector<Object[]> users = new Vector<Object[]>();

@Override
public boolean connect (IConnection conn, IScope scope, Object [] params)
{
    Log ("Connect");
    if (params == null || params.length == 0)
    {
        rejectClient ("No username passed.");
    }
    if ( ! super.connect (conn, scope, params))
    {
        return false;
    }
    String username = params [0].toString ();
    String uid = conn.getClient ().getId ();
    if ( ! existUsername (username))
    {
        users.addElement (new Object []
        {
            new String (username ) , new String (uid )
        } );
        ServiceUtils.invokeOnAllConnections ("UpdateUserList", new Object []
        {
            users
        });
    }
    else
    {
        rejectClient ("Username already token");
    }
    return true;
}

Here everything goes well, and when a user logs off:


@Override
public void disconnect (IConnection conn, IScope scope)
{
    //ServiceUtils.invokeOnAllConnections( "UpdateUserList", new 
Object[] {users});
    Log ("Disconnect");
    String uid = conn.getClient ().getId ();
    if (uid != null)
    {
        for (int i = 0; i < users.size (); i ++)
        {
            if (uid.equals (users.elementAt (i)[1].toString ()))
            {
                Log ("Delete: " + users.elementAt (i)[1].toString ());
                users.removeElementAt (i);
                break;
            }
        }
    }
    else
    {
        super.disconnect (conn, scope);
    }
}




but, with the line

ServiceUtils.invokeOnAllConnections( "UpdateUserList", new Object[] 
{users});

the log fails with:

[java] [ERROR] 23875 IoWorker-1:( org.red5.server.Scope.error ) Error 
while executing "disconnect" for connection RTMPMinaConnection from 
127.0.0.1:1570 to
 localhost (in: 3356, out: 3240) on handler [EMAIL PROTECTED]
[java] java.lang.NullPointerException
[java]     at 
org.red5.server.api.service.ServiceUtils.invokeOnAllConnections(ServiceUtils.java:132)
[java]     at 
org.red5.server.api.service.ServiceUtils.invokeOnAllConnections(ServiceUtils.java:118)
[java]     at sapoChat.Application.disconnect(Application.java:57)

Any ideas?

That's all folks :), thanks for your help.


-- 
Enrique Chavez aka Tmeister
http://www.klr20mg.com
http://www.tmeister.net
http://desktoptwo.com



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

Reply via email to