From 05f8bfe906067d9edd86d77ebc6a7a6f3294fe14 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 29 Aug 2017 15:43:52 +0300 Subject: [PATCH] Deleting a user should log them out Fixes #916 --- src/client.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/client.js b/src/client.js index ef3f5ce2..01110fac 100644 --- a/src/client.js +++ b/src/client.js @@ -491,14 +491,20 @@ Client.prototype.names = function(data) { }; Client.prototype.quit = function() { - var sockets = this.sockets.sockets; - var room = sockets.adapter.rooms[this.id] || []; - for (var user in room) { - var socket = sockets.adapter.nsp.connected[user]; - if (socket) { - socket.disconnect(); + const sockets = this.sockets.sockets; + const room = sockets.adapter.rooms[this.id]; + + if (room && room.sockets) { + for (const user in room.sockets) { + const socket = sockets.connected[user]; + + if (socket) { + socket.emit("sign-out"); + socket.disconnect(); + } } } + this.networks.forEach((network) => { if (network.irc) { network.irc.quit(Helper.config.leaveMessage);