From bd5e11c46a8521d801a8b632d42850496edc2599 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Mon, 17 Mar 2014 16:43:47 -0500 Subject: [PATCH] Fix empty channel issue --- lib/channel.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/channel.js b/lib/channel.js index ec3c2914..46884dce 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -466,6 +466,14 @@ Channel.prototype.getIPRank = function (ip, callback) { */ Channel.prototype.preJoin = function (user, password) { var self = this; + + // Allow channel to unload if the only user disconnects without finishing a join + user.socket.on("disconnect", function () { + if (!user.inChannel() && self.users.length === 0) { + self.emit("empty"); + } + }); + self.whenReady(function () { if (self.dead) { return;