Pierre Clocher
Pierre Clocher

Reputation: 1117

How to know the number of connected sockets in a given pool

Everything in the title.

io.on('connection', (socket) => {
  socket.join('somepool');
  // Here I want to know how many socket's connections are opened in the given pool
  // Something like:
  io.in('somepool').length;
});

Upvotes: 0

Views: 54

Answers (1)

mdatsev
mdatsev

Reputation: 3879

You can use io.sockets.clients('somepool') to get all the clients connected and io.sockets.clients('somepool').length to get the number of connections.

Upvotes: 1

Related Questions