Hello I'm trying to loop through all connected sockets and check if they have the session data (userid) I'm looking for. Here's my code (doesn't work):
var clients = io.sockets.clients();
console.log(clients);
for(i = 0; i < clients.length; i++) {
if(clients[i].handshake.session.userid == userid) {
clients[i].emit(event, data);
}
}
My question is how I could find an array of sockets since io.sockets.clients() doesn't seem to return an array with the socket objects.