- this.newChat = data.chat;
- break;
- case "refusechallenge":
- ArrayFun.remove(this.challenges, c => c.id == data.cid);
- alert(this.st.tr["Challenge declined"]);
- break;
- case "deletechallenge":
- // NOTE: the challenge may be already removed
- ArrayFun.remove(this.challenges, c => c.id == data.cid);
- break;
- case "connect":
- case "gconnect":
- this.$set(this.people, data.from, {name:"", id:0, gamer:data.code[0]=='g'});
- this.st.conn.send(JSON.stringify({code:"askidentity", target:data.from}));
- if (data.code == "connect")
- this.st.conn.send(JSON.stringify({code:"askchallenge", target:data.from}));
- else
- this.st.conn.send(JSON.stringify({code:"askgame", target:data.from}));
- break;
- case "disconnect":
- case "gdisconnect":
- this.$delete(this.people, data.from);
- if (data.code == "disconnect")
- {
- // Also remove all challenges sent by this player:
- ArrayFun.remove(this.challenges, c => c.from.sid == data.from);
- }
- else
- {
- // And all live games where he plays and no other opponent is online
- ArrayFun.remove(this.games, g =>
- g.type == "live" && (g.players.every(p => p.sid == data.from
- || !this.people[p.sid])), "all");
- }