How to get room’s clients list in socket.io 1.0

Consider this rather more complete answer linked in a comment above on the question: https://stackoverflow.com/a/24425207/1449799


The clients in a room can be found at

io.nsps[yourNamespace].adapter.rooms[roomName]

This is an associative array with keys that are socket ids. In our case, we wanted to know the number of clients in a room, so we did Object.keys(io.nsps[yourNamespace].adapter.rooms[roomName]).length

In case you haven’t seen/used namespaces (like this guy[me]), you can learn about them here http://socket.io/docs/rooms-and-namespaces/ (importantly: the default namespace is “https://stackoverflow.com/”)

Updated (esp. for @Zettam):

checkout this repo to see this working: https://github.com/thegreatmichael/socket-io-clients

Leave a Comment