我有socket.io这个场景:
套接字连接并加入一个房间,他就是主人.其他插座加入他的房间.当主人断开连接时,我想从这个房间踢出所有其他插座.
我想到了这个:
socket.on('disconnect', function(data){
// if socket's id == room he is the master and kick other sockets from this
// room and join them to a room of their own identified by their ids.
});
Run Code Online (Sandbox Code Playgroud)
我想这样做没有太多的逻辑和循环停止应用程序.这样的事情有可能io.sockets.leave(socket.room)吗?