Suppor string game updates and better setStatus logic

This commit is contained in:
abalabahaha
2015-12-24 02:07:05 -08:00
parent 7819dcb3d1
commit 8c39ddc48d
4 changed files with 20 additions and 5721 deletions

View File

@@ -824,31 +824,33 @@ export default class InternalClient {
}
//def setStatus
setStatus(idleStatus, gameID) {
setStatus(idleStatus, game) {
this.idleStatus = idleStatus || this.idleStatus || null;
if(idleStatus){
if(idleStatus === "online" || idleStatus === "here" || idleStatus === "available"){
this.idleStatus = null;
}
if(idleStatus === "online" || idleStatus === "here" || idleStatus === "available"){
this.idleStatus = null;
}
this.gameID = this.resolver.resolveGameID(gameID) || this.gameID || null;
else if (this.idleStatus === "idle" || this.idleStatus === "away") {
packet.d.idle_since = Date.now();
}
else {
this.idleStatus = this.idleStatus || null; //undefineds
}
this.game = game === null ? null : game || this.game;
var packet = {
op: 3,
d: {
idle_since: this.idleStatus,
game_id: this.gameID
game: {
name: this.game
}
}
};
if (this.idleStatus === "idle" || this.idleStatus === "away") {
packet.d.idle_since = Date.now();
}
this.sendWS(packet);
return Promise.resolve();//why?
return Promise.resolve();
}