[Red5] Getting a List of Users?
Andy
bowljoman at hotmail.com
Wed Oct 24 13:45:40 PDT 2007
//Attribute are your(My) best friend
if(params[2].equals(someValue))//user stream subscriber;
{
conn.getClient().setAttribute("ehandler", false);
conn.getClient().setAttribute("strname","no");
conn.getClient().setAttribute("user", "no");
conn.getClient().setAttribute("sub", "no");
conn.getClient().setAttribute("owner", params[3]);
return super.appConnect(conn, params);//subscriber stream
}
I learned most stuff in c++/direct show, so Im used to enumerating
things when needed
public String[] getSubs() {
Object
objMyName=Red5.getConnectionLocal().getClient().getAttribute("owner");
int i=0;
Iterator<IConnection> conns =appScope.getConnections();
while(conns.hasNext())
{
IConnection acon=(IConnection)conns.next();
Object bcast=acon.getClient().getAttribute("user");
Object bcast2=acon.getClient().getAttribute("ehandler");
if (bcast.equals("no")&& bcast2.equals(false) )
{
Object pubAtb =acon.getClient().getAttribute("strname");
if(pubAtb.equals(objMyName))
{
i++;
}
}
}
if(i==0)
{
String[] ret=new String[1];
ret[0]="No Subscribers";
return ret;
}
String[] peeps=new String[i+1];
i=1;
peeps[0]="My Subscribers";
Iterator<IConnection> conns2 =appScope.getConnections();
while(conns2.hasNext())
{
IConnection acon=(IConnection)conns2.next();
Object bcast=acon.getClient().getAttribute("user");
if (bcast.equals("no"))
{
Object pubAtb =acon.getClient().getAttribute("strname");
if(pubAtb.equals(objMyName))
{
Object pubAtb2 =acon.getClient().getAttribute("owner");
peeps[i]=(String)pubAtb2;
i++;
}
}
}
return peeps;
}
-----Original Message-----
From: red5-bounces at osflash.org [mailto:red5-bounces at osflash.org] On
Behalf Of abogartz makaimedia.com
Sent: Wednesday, October 24, 2007 10:52 AM
To: red5 at osflash.org; red5 at osflash.org
Subject: Re: [Red5] Getting a List of Users?
Hmm, pardon me on this, but have I overlooked this? I can't seem to
find much in the way of code snippets. Can you direct me to a some
online resources with code examples?
Also, will this method return me a list of Id's or a list of names? I
need to have both in Flash.
Thanks!
-----Original Message-----
From: red5-bounces at osflash.org on behalf of dev at binarycrafts.com
Sent: Wed 10/24/2007 1:16 PM
To: red5 at osflash.org
Subject: Re: [Red5] Getting a List of Users?
You use the client.getId() in red 5 to get the unique id associated with
that user and you put that in a 'roomClients' SharedObject that all your
flash clients connect to. Should be some code online about that.
cosmin
> Hi there, I've gotten Red 5 working, and so now I'm trying to delve
into
> the various functions.
>
> I've copied over the following connect method:
>
> private ClientManager clientMgr = new ClientManager("clientlist",
> false);
>
> public boolean connect(IConnection conn, IScope scope, Object[]
> params) {
> // Check if the user passed valid parameters.
> if (params == null || params.length == 0) {
> log.debug("Client didn't pass a username.");
> // NOTE: "rejectClient" terminates the execution
> of the current method!
> rejectClient("No username passed.");
> }
>
> // Call original method of parent class.
> if (!super.connect(conn, scope, params)) {
> return false;
> }
>
> String username = params[0].toString();
> String uid = conn.getClient().getId();
> if (log.isDebugEnabled()) {
> log.debug("Client \"" + username + "\" (" + uid
> + ") connected.");
> }
> // Register the user in the shared object.
> clientMgr.addClient(scope, username, uid);
> // Notify client about unique id.
> ServiceUtils.invokeOnConnection(conn, "setClientID",
> new Object[] { uid });
> return true;
> }
>
> What I'd like to do is that whenever someone connects, everyone in the
> room gets an updated list of users. How might I handle that? I
assume
> I iterate through some list, but I'm not sure. Any help would be
> appreciated!
>
> Thanks!
>
>
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
>
_______________________________________________
Red5 mailing list
Red5 at osflash.org
http://osflash.org/mailman/listinfo/red5_osflash.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/red5_osflash.org/attachments/20071024/3436a12d/attachment-0001.html
More information about the Red5
mailing list