I'm new to node.js and javascript. I'm using socket.io and trying to list sockets connected in a given room. When a socket connects I give it a nickname:
io.use(function (socket, next) {
var handshakeUserid = socket.request._query.userid;
socket.nickname = handshakeUserid;
next();
});
With this code I can get the id's of the sockets:
for (socketID in io.nsps['/'].adapter.rooms[room_name].sockets) {
console.log(socketID);
}
But how can I access the nickname property in this loop? Trying socketID.nickname, or socketID[nickname] will trow an error nickname is not define.