From: Benjamin Auder Date: Sat, 8 Dec 2018 14:14:41 +0000 (+0100) Subject: Fix newgame bug (seek-cancel-seek should not create a game) X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/css/user/doc/pieces/%7B%7B%20targetUrl%20%7D%7D?a=commitdiff_plain;h=283d06a4401a937d602c4b863201945f1be3e701;p=vchess.git Fix newgame bug (seek-cancel-seek should not create a game) --- diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 1178b64a..9ecba0cb 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -667,6 +667,7 @@ Vue.component('my-game', { return; //no newgame while playing if (this.seek) { + this.conn.send(JSON.stringify({code:"cancelnewgame"})); delete localStorage["newgame"]; //cancel game seek this.seek = false; } diff --git a/sockets.js b/sockets.js index 452cb6e0..ee4c1cfd 100644 --- a/sockets.js +++ b/sockets.js @@ -88,6 +88,9 @@ module.exports = function(wss) { else games[page] = {id:sid, fen:obj.fen}; //wait for opponent break; + case "cancelnewgame": //if a user cancel his seek + delete games[page]; + break; case "resign": if (!!clients[page][obj.oppid]) clients[page][obj.oppid].send(JSON.stringify({code:"resign"}), noop);