I'm trying to get a list of all the sockets/clients that are currently connected.
io.sockets
does not return an array, unfortunately.
I know I could keep my own list using an array, but don't think this is an optimal solution for 2 reasons:
Redundancy. Socket.IO already keeps a copy of this list.
Socket.IO provides method to set arbitrary field values for clients (i.e: socket.set('nickname', 'superman')
) so I'd need to keep up with these changes if I were to maintain my own list.
Help?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…