Fix empty channel issue

This commit is contained in:
calzoneman 2014-03-17 16:43:47 -05:00
parent 07819f0b14
commit bd5e11c46a
1 changed files with 8 additions and 0 deletions

View File

@ -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;