+ case "identity":
+ {
+ let player = this.people.find(p => p.sid == data.user.sid);
+ // NOTE: sometimes player.id fails because player is undefined...
+ // Probably because the event was meant for Hall?
+ if (!player)
+ return;
+ player.id = data.user.id;
+ player.name = data.user.name;
+ // Sending last state only for live games: corr games are complete
+ if (this.game.type == "live" && this.game.oppsid == player.sid)
+ {
+ // Send our "last state" informations to opponent
+ const L = this.game.moves.length;
+ this.st.conn.send(JSON.stringify({
+ code: "lastate",
+ target: player.sid,
+ state:
+ {
+ lastMove: (L>0 ? this.game.moves[L-1] : undefined),
+ score: this.game.score,
+ movesCount: L,
+ drawOffer: this.drawOffer,
+ clocks: this.game.clocks,
+ }
+ }));
+ }
+ break;
+ }
+ case "askgame":
+ // Send current (live) game
+ const myGame =
+ {
+ // Minimal game informations:
+ id: this.game.id,
+ players: this.game.players.map(p => { return {name:p.name}; }),
+ vid: this.game.vid,
+ timeControl: this.game.timeControl,
+ };
+ this.st.conn.send(JSON.stringify({code:"game",
+ game:myGame, target:data.from}));
+ break;
+ case "newmove":
+ // NOTE: this call to play() will trigger processMove()
+ this.$refs["basegame"].play(data.move,
+ "receive", this.game.vname!="Dark" ? "animate" : null);
+ break;