List Info

Thread: Calling a client method on all connected clients




Calling a client method on all connected clients
user name
2006-06-21 18:11:38
I swear, if I could understand how to read the damn Java docs properly I'd be better off. As is, I've reviewed much of the API and I still have issues. (I guess I am better at following examples rather than JavaDocs).

In our application I have to tell all the connected users that this person has joined when a new user joins.

Is there a direct method of doing this? getAllConnections().invoke(";newuserlogged", id); or something like that
Or do I need to hold on to references of connections and loop through then to invoke something?

Leif


Calling a client method on all connected clients
user name
2006-06-21 18:36:37
Hi Leif,

Leif Wells wrote:
> I swear, if I could understand how to read the damn
Java docs properly
> I'd be better off. As is, I've reviewed much of the
API and I still have
> issues. (I guess I am better at following examples
rather than JavaDocs).
> 
> In our application I have to tell all the connected
users that this
> person has joined when a new user joins.
> 
> Is there a direct method of doing this?
> getAllConnections().invoke("newuserlogged",
id); or something like that
> Or do I need to hold on to references of connections
and loop through
> then to invoke something?

I'll add a utility class for stuff like this.  Here are two
sample
methods for you to use in the meantime:

import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import
org.red5.server.api.service.IServiceCapableConnection;

/**
 * Invoke a method on a given connection.
 *
 * param conn
 * param method
 * param params
 */
public static void invokeOnClient(IConnection conn, String
method,
                                  Object[] params) {
	if (conn instanceof IServiceCapableConnection)
		((IServiceCapableConnection) conn).invoke(method, params);
}

/**
 * Invoke a method on all connections to a given scope.
 *
 * param scope
 * param method
 * param params
 */
public static void invokeOnAllClients(IScope scope, String
method,
                                      Object[] params) {
	List<IConnection> connections = new
ArrayList<IConnection>();
	Iterator<IConnection> iter = scope.getConnections();
	while (iter.hasNext())
		connections.add(iter.next());
	
	for (IConnection conn: connections)
		invokeOnClient(conn, method, params);
}

Joachim

_______________________________________________
Red5 mailing list
Red5osflash.org

http://osflash.org/mailman/listinfo/red5_osflash.org
Calling a client method on all connected clients
user name
2006-06-21 19:52:39
Joachim Bauch wrote:
[...]
> I'll add a utility class for stuff like this.  Here
are two sample
> methods for you to use in the meantime:

The utility class is now available in the trunk as
"org.red5.server.api.service.ServiceUtils".

Joachim

_______________________________________________
Red5 mailing list
Red5osflash.org

http://osflash.org/mailman/listinfo/red5_osflash.org
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )