From 51e621212053699477b334e6927421c96c5e6efa Mon Sep 17 00:00:00 2001 From: Ivan Fraixedes Date: Thu, 8 Aug 2013 13:55:41 +0100 Subject: [PATCH] Removed the socket from its namespace when the client disconnect it (disconnect the socket from a namespace no the global socket) and release the attached socket's event listeners --- lib/socket.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/socket.js b/lib/socket.js index d9807f6dd2..0be4dde817 100644 --- a/lib/socket.js +++ b/lib/socket.js @@ -301,9 +301,15 @@ Socket.prototype.disconnect = function () { } else { this.packet({type: 'disconnect'}); this.manager.onLeave(this.id, this.namespace.name); - this.$emit('disconnect', 'booted'); + + if (this.namespace.sockets[this.id]) { + this.removeAllListeners(); + delete this.namespace.sockets[this.id]; + } + } + this.onDisconnect('booted'); } return this;