X-Git-Url: https://git.auder.net/variants/Baroque/style.css?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=cadda013897fdd3000cd7623f91d2217d4a9f4d0;hb=cd0d7743323309fcfd241ccba959df81a77970c7;hp=8fbc9d0b0d90028fe520ccf80e8dd277c471172d;hpb=5c8e044f7bab43ca8573fdf631f9b87daeda3ad0;p=vchess.git diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 8fbc9d0b..cadda013 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -162,6 +162,10 @@ export default { 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 @@ -184,6 +188,19 @@ export default { } break; } + case "askgame": + // Send current (live) game + const myGame = + { + // Minimal game informations: + id: this.game.id, + players: this.game.players.map(p => 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, @@ -235,12 +252,12 @@ export default { // ==> on "newmove", check "drawOffer" field case "connect": { - this.people.push({name:"", id:0, sid:data.sid}); - this.st.conn.send(JSON.stringify({code:"askidentity", target:data.sid})); + this.people.push({name:"", id:0, sid:data.from}); + this.st.conn.send(JSON.stringify({code:"askidentity", target:data.from})); break; } case "disconnect": - ArrayFun.remove(this.people, p => p.sid == data.sid); + ArrayFun.remove(this.people, p => p.sid == data.from); break; } },