Socket.IO transmitting a array per emit(...)
Problem
I am trying to build a Array in my socket io server and sending it to the client.
var roomList = io.sockets.manager.rooms;
// new Array to save the clients per room
var clientsPerRoom = new Array();
//for (var i = 0; i
On the client side
var clients = 1;
for (room in roomList) {
if (room.length > 0) {
room = room.replace("/", "");
clients = clientsPerRoom[room];
console.log("ROOM: '" + room + "' has '" + clients + "' CLIENTS");
}
}
At the client, "clientsPerRoom" is "[]" (empty?), and so "clients" is "undeined". What am I doing wrong?
At the console log from the server are the values 1 if a user is connectet. If more users are online then its still 1 but at least it should send this value to the client.
Thanks
Problem courtesy of: Mexx
Solution
Even solved yet.
Problem was: io.sockets.clients(room) only counts users who accepted webcam access, otherwise the are not "really" in the room yet.
Greetings
Solution courtesy of: Mexx
Discussion
View additional discussion.