Socket.IO 1.0.x: Get socket by id
Version 3.0.3
// in "of", you can put '/' or whatever namespace you're using
io.of('/').sockets.get(socketId)
Basically, sockets
is no longer a simple Object. It's a Map, so you have to use .get()
.
For socket.io 1.0 use:
io.sockets.connected[socketId]
For 0.9 its io.sockets.sockets[socketId] and not io.sockets.socket[socketId]
you can also use like:
io.to(socketid).emit();
Socket.io Version 4.0.0
io.sockets.sockets.get(socketId);