Single source of truth for AFK

Resolves #678
This commit is contained in:
Xaekai 2017-06-15 21:48:17 -07:00
parent 00a65a1584
commit df0fc769d9
2 changed files with 6 additions and 5 deletions

View file

@ -417,6 +417,10 @@ Channel.prototype.acceptUser = function (user) {
if (!this.is(Flags.C_REGISTERED)) { if (!this.is(Flags.C_REGISTERED)) {
user.socket.emit("channelNotRegistered"); user.socket.emit("channelNotRegistered");
} }
user.on('afk', function(){
self.sendUserMeta(self.users, user, -1);
})
}; };
Channel.prototype.partUser = function (user) { Channel.prototype.partUser = function (user) {

View file

@ -226,10 +226,7 @@ User.prototype.setAFK = function (afk) {
this.channel.modules.voteskip.update(); this.channel.modules.voteskip.update();
} }
this.channel.broadcastAll("setAFK", { this.emit('afk', afk);
name: this.getName(),
afk: afk
});
}; };
/* Automatically tag a user as AFK after a period of inactivity */ /* Automatically tag a user as AFK after a period of inactivity */
@ -424,7 +421,7 @@ User.prototype.getFirstSeenTime = function getFirstSeenTime() {
return this.socket.ipSessionFirstSeen.getTime(); return this.socket.ipSessionFirstSeen.getTime();
} else { } else {
LOGGER.error(`User "${this.getName()}" (IP: ${this.realip}) has neither ` + LOGGER.error(`User "${this.getName()}" (IP: ${this.realip}) has neither ` +
"an IP sesion first seen time nor a registered account."); "an IP session first seen time nor a registered account.");
return Date.now(); return Date.now();
} }
}; };