Is it possible to listen for join and leave events on a room?

后端 未结 4 635

I want to do something like:

var room = io.sockets.in(\'some super awesome room\');
room.on(\'join\', function () {
    /* stuff */
});
room.on(\'leave\', functi         


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-02-05 14:53

    You can use the native "disconnect" event.

    socket.on('disconnect', function () {
    
            io.sockets.emit('user disconnected');
        });
    

提交回复
热议问题