diff --git a/lib/manager.js b/lib/manager.js index 5103b00af3..b77b9d6428 100644 --- a/lib/manager.js +++ b/lib/manager.js @@ -468,13 +468,14 @@ Manager.prototype.onClientMessage = function (id, packet) { * @api private */ -Manager.prototype.onClientDisconnect = function (id, reason) { +Manager.prototype.onClientDisconnect = function (id, reason, local) { for (var name in this.namespaces) { this.namespaces[name].handleDisconnect(id, reason, typeof this.roomClients[id] !== 'undefined' && typeof this.roomClients[id][name] !== 'undefined'); } - this.onDisconnect(id); + if (local) this.store.publish('disconnect', id); + this.onDisconnect(id, local); }; /** diff --git a/lib/transport.js b/lib/transport.js index 61f456fce9..540d67f956 100644 --- a/lib/transport.js +++ b/lib/transport.js @@ -457,14 +457,15 @@ Transport.prototype.end = function (reason) { if (!this.disconnected) { this.log.info('transport end'); - var local = this.manager.transports[this.id]; + var local = !!this.manager.transports[this.id]; this.close(); this.clearTimeouts(); this.disconnected = true; + if (local) { - this.manager.onClientDisconnect(this.id, reason, true); + this.manager.onClientDisconnect(this.id, reason, local); } else { this.store.publish('disconnect:' + this.id, reason); }