X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=433151c72b831f0df0cf5684ccba9ebd59c2665e;hp=82330ef13afccdb86c52fe0a471291a700481003;hb=411d23cd80a2dbf53d21008976d34e7f450154bf;hpb=3d55deea9a2011c38d8d0067bd57fc889958bec2 diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 82330ef1..433151c7 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -550,20 +550,29 @@ export default { if (!!opponent) target = opponent.sid } - if (!!target) //opponent is online - { - this.st.conn.send(JSON.stringify({code:"newgame", - gameInfo:gameInfo, target:target, cid:c.id})); - } + const tryNotifyOpponent = () => { + if (!!target) //opponent is online + { + this.st.conn.send(JSON.stringify({code:"newgame", + gameInfo:gameInfo, target:target, cid:c.id})); + } + }; if (c.type == "live") + { + tryNotifyOpponent(); this.startNewGame(gameInfo); + } else //corr: game only on server { ajax( "/games", "POST", {gameInfo: gameInfo, cid: c.id}, //cid useful to delete challenge - response => { this.$router.push("/game/" + response.gameId); } + response => { + gameInfo.gameId = response.gameId; + tryNotifyOpponent(); + this.$router.push("/game/" + response.gameId); + } ); } },