如果套接字已从服务器断开连接,则该套接字的所有订阅将默认(通过帆)从聊天室中删除,还是我们必须手动(通过代码)将其删除
答案 0 :(得分:1)
socket.io source code this.leaveAll()
的基础将在火灾断开事件之前运行。因此无需手动离开房间
Socket.prototype.onclose = function(reason){
if (!this.connected) return this;
debug('closing socket - reason %s', reason);
this.emit('disconnecting', reason);
this.leaveAll(); // leave from all rooms
this.nsp.remove(this);
this.client.remove(this);
this.connected = false;
this.disconnected = true;
delete this.nsp.connected[this.id];
this.emit('disconnect', reason); // disconnect event fire here
};