View Full Version : Number of connections
grone2001
12-11-2007, 07:12 PM
Hi, I have a simple chat type; all I need is a simple piece of code that would show the amount of people currently connected to the chat. Something saying... (16 users connected) It's just a simple .exe that connects to the server just using netConn = new NetConnection(); kind of thing....
Any help would be greatly appreciated!!
Lorem Ipsum
12-29-2007, 07:47 PM
You could call a client method from the server-side code, sending the amount of people currently connected, as the application knows how many clients are connected to it.
//server side
application.onConnection = function(newClient) {
//accept the client here, and everything else you have to do
for(i=0;i<application.clients.length;i++) {
application.clients[i].call("numberOfClients",null,application.clients.length);
}
//you should do the same onDisconnect
}
//client side
net_con.numberOfClients = function(nClients) {
_root.clientsOnline.text=nClients;
}
I'm new at FMS and I didn't try this code, but I hope it's usefull. I don't know how would this work if you have rooms (instances) in your chat application, though.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.