通过 application.clients.length 就可以了
客户端需要的话可以call服务器端定义的函数,最方便的还是使用共享对象来存取了,下面给出完整的实现方法。
在服务器端的main.asc文件中写入:
application.onAppStart = function() {
this.users_so = SharedObject.get('users_so',true);
};
application.onConnect = function(newClient, name)
{
// Accept the client's connection
application.acceptConnection(newClient);
i = application.clients.length; //获得在线总人数
this.users_so.setProperty('users', i);
}
application.onDisconnect = function(client)
{
i = application.clients.length;
this.users_so.setProperty('users', i);
}
在客户端fla文件中添加:
users_so = SharedObject.getRemote('users_so', client_nc.uri, false);
// 更新在线用户数
users_so.onSync = function(list) {
txtNumberUsers.text = users_so.data.users;
}
客户端需要的话可以call服务器端定义的函数,最方便的还是使用共享对象来存取了,下面给出完整的实现方法。
在服务器端的main.asc文件中写入:
application.onAppStart = function() {
this.users_so = SharedObject.get('users_so',true);
};
application.onConnect = function(newClient, name)
{
// Accept the client's connection
application.acceptConnection(newClient);
i = application.clients.length; //获得在线总人数
this.users_so.setProperty('users', i);
}
application.onDisconnect = function(client)
{
i = application.clients.length;
this.users_so.setProperty('users', i);
}
在客户端fla文件中添加:
users_so = SharedObject.getRemote('users_so', client_nc.uri, false);
// 更新在线用户数
users_so.onSync = function(list) {
txtNumberUsers.text = users_so.data.users;
}