From 8701c3d2f0b49b68ac36d568c3045055a8f107b6 Mon Sep 17 00:00:00 2001 From: Halit Aksoy Date: Wed, 7 Sep 2022 21:13:06 +0300 Subject: [PATCH] fix listenUserConnectionChange --- src/game/GameManager.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/game/GameManager.ts b/src/game/GameManager.ts index a1c88e2..a92c4d8 100644 --- a/src/game/GameManager.ts +++ b/src/game/GameManager.ts @@ -191,8 +191,12 @@ export class GameManager { this.rtmt.listenOnClientConnectionChange((clientId: string, isOnline: boolean) => { const game = this.gameStore.getGameByUser(clientId); if (game) this.sendUserConnectionInfo(game); - const speactatingGameIds = this.gameStore.getSpeactatingGameIdsByUser(clientId); - speactatingGameIds.forEach((gameId) => this.removeSpectator(clientId, gameId)); + if (!isOnline) { + const speactatingGameIds = this.gameStore.getSpeactatingGameIdsByUser(clientId); + speactatingGameIds.forEach((gameId) => this.removeSpectator(clientId, gameId)); + } else { + game && this.rtmt.sendMessage(clientId, channel_on_game_update, game); + } }); } } \ No newline at end of file