在socket.io,socket.leave()断开连接时我是否需要手动呼叫?
或者NodeJs Socket.io自己处理它?
socket.on("disconnect" function() {
this.leave("room"); // is this necessary?
});
Run Code Online (Sandbox Code Playgroud)
Sha*_*yar 14
不,所有房间在发布此活动之前已经离开.
Socket.prototype.onclose = function(reason){
if (!this.connected) return this;
debug('closing socket - reason %s', reason);
this.emit('disconnecting', reason);
this.leaveAll(); //leaving 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); //emitting event
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4888 次 |
| 最近记录: |