当套接字与服务器断开连接时如何从房间取消订阅套接字

How to unsubscribe a socket from a room when socket disconnected from the server

如果套接字与服务器断开连接,该套接字的所有订阅会默认从聊天室中删除(通过 sails)还是我们必须手动删除(通过代码)

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
};