X-Git-Url: https://git.auder.net/variants/Chakart/style.css?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=062990d2e8b492cda2c3d0753a06c5249bc0bbfa;hb=48ab808f1454463ca2b960d6301fa0f47f21b4ad;hp=b7cc1fc08ef1ccb72852b9f926b331d8df1101a4;hpb=a154d45ebb7e409cd714d0c517e79c8147bdea69;p=vchess.git diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index b7cc1fc0..062990d2 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -134,7 +134,11 @@ export default { if (!!this.conn && this.conn.readyState == 1) //1 == OPEN state callback(); else //socket not ready yet (initial loading) - this.conn.onopen = callback; + { + // NOTE: it's important to call callback without arguments, + // otherwise first arg is Websocket object and loadGame fails. + this.conn.onopen = () => { return callback() }; + } }; if (!this.gameRef.rid) //game stored locally or on server this.loadGame(null, () => socketInit(this.roomInit)); @@ -540,7 +544,8 @@ export default { }); if (this.repeat[repIdx] >= 3) this.drawOffer = "threerep"; - callback(); + if (!!callback) + callback(); }; if (!!game) return afterRetrieval(game); @@ -681,6 +686,8 @@ export default { { GameStorage.update(this.gameRef.id, {score: score, scoreMsg: scoreMsg}); + // Notify the score to main Hall. TODO: only one player (currently double send) + this.send("result", {gid:this.game.id, score:score}); } }, },