fix listenUserConnectionChange

This commit is contained in:
Halit Aksoy 2022-09-07 21:13:06 +03:00
parent f6c4db1b8d
commit 8701c3d2f0

View File

@ -191,8 +191,12 @@ export class GameManager {
this.rtmt.listenOnClientConnectionChange((clientId: string, isOnline: boolean) => { this.rtmt.listenOnClientConnectionChange((clientId: string, isOnline: boolean) => {
const game = this.gameStore.getGameByUser(clientId); const game = this.gameStore.getGameByUser(clientId);
if (game) this.sendUserConnectionInfo(game); if (game) this.sendUserConnectionInfo(game);
if (!isOnline) {
const speactatingGameIds = this.gameStore.getSpeactatingGameIdsByUser(clientId); const speactatingGameIds = this.gameStore.getSpeactatingGameIdsByUser(clientId);
speactatingGameIds.forEach((gameId) => this.removeSpectator(clientId, gameId)); speactatingGameIds.forEach((gameId) => this.removeSpectator(clientId, gameId));
} else {
game && this.rtmt.sendMessage(clientId, channel_on_game_update, game);
}
}); });
} }
} }