C
C
CanVeeD2016-02-12 23:01:24
Node.js
CanVeeD, 2016-02-12 23:01:24

How to get a list of socket.io 1.0 room connections?

I have a specific room and I need to find out how many people are in a specific room. I'm using the latest Socket.Io. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nicholas, 2016-02-13
@ACCNCC

function getClient(roomId) {
  var res = [],
      room = io.sockets.adapter.rooms[roomId];
  if (room) {
    for (var id in room) {
      res.push(io.sockets.adapter.nsp.connected[id]);
    }
  }
  return res;
}

socket.io is full of holes as always) see the news!
Great replacement https://www.npmjs.com/package/websocket

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question