Socket.io Connected User Count

后端 未结 12 859
有刺的猬
有刺的猬 2021-01-30 20:24

I finally got socket.io to work properly, but I have encountered a strange problem.

I am not sure if this is the best way, but I am using:

io.sockets.cli         


        
12条回答
  •  情话喂你
    2021-01-30 21:04

    I am currently using socket v1.4.29 with typeScript, you can find the number of clients connected by using this

     io.sockets.on('connection', function(socket) {
     var clients = socket.client.conn.emit.length;
     console.log("clients: " + clients);
     });
    

提交回复
热议问题