From 48ab808f1454463ca2b960d6301fa0f47f21b4ad Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Thu, 13 Feb 2020 15:05:36 +0100 Subject: [PATCH] Pass result to Hall after a game ends --- client/src/views/Game.vue | 2 ++ client/src/views/Hall.vue | 7 +++++++ server/sockets.js | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index e83b9886..062990d2 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -686,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}); } }, }, diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index de6d6d15..9b584095 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -548,6 +548,13 @@ export default { } break; } + case "result": + { + let g = this.games.find(g => g.id == data.gid); + if (!!g) + g.score = data.score; + break; + } case "startgame": { // New game just started: data contain all information diff --git a/server/sockets.js b/server/sockets.js index 7f0d14ec..3fb7ea2a 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -186,6 +186,11 @@ module.exports = function(wss) { notifyRoom(page, obj.code, {data:obj.data}); break; + case "result": + // Special case: notify all, 'transroom': Game --> Hall + notifyRoom("/", "result", {gid:obj.gid, score:obj.score}); + break; + // Passing, relaying something: from isn't needed, // but target is fully identified (sid + tmpId) case "challenge": -- 2.44.0