Socket.io: How to count clients in a room with Socket.io-redis adapter

后端 未结 3 564
执念已碎
执念已碎 2021-02-05 14:19

I start building chat server using Socket.io with multiple nodes. It uses Socket.io-redis to connect all servers together and rooms for messaging.

When a client connects

3条回答
  •  别那么骄傲
    2021-02-05 15:10

    This method works perfectly:

    io.sockets.adapter.clients(["room1"], function(err, clients){
      console.log("total clients in room1: %d", clients.length);
    })
    

提交回复
热议问题