Is it possible to get rooms which socket is currently in, without calling
io.sockets.clients(roomName)
for every room name and looking for
Socket.io v2.1.1
So make sure you aren't accessing the sockets rooms in the disconnect
event like I was, as they have already left the rooms by the time that event is triggered. If you want to do that try it in the disconnecting
event - https://github.com/socketio/socket.io/pull/2332/files
Then you can use any of the following:
Object.keys(socket.adapter.rooms)
Object.keys(socket.adapter.sids)
Object.keys(socket.rooms)