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;