I have this code right now that sets the nick and room:
io.sockets.on('connection', function(client){
var Room = "";
client.on("setNickAndRoom", function(nick, fn){
client.join(nick.room);
Room = nick.room;
client.broadcast.to(Room).emit('count', "Connected:" + " " + count);
fn({msg :"Connected:" + " " + count});
});
I wanted to know how I could get how many people are connected to a specific chatroom...like Room.length
client side :
function Chat(){
this.socket = null;
this.Nickname = "";
this.Room = "";
var synched = $('#syncUp');
this.Connect = function(nick, room){
socket = io.connect('http://vybeing.com:8080');
Nickname = nick;
Room = room;
//conectarse
socket.on('connect',function (data) {
socket.emit('setNickAndRoom', {nick: nick, room: room}, function(response){
$("#connection").html("<p>" + response.msg + "</p>");
});
});
}
I found this, but it gives undefined:
count = io.rooms[Room].length;