diff --git a/back/volume/src/pong/game/Games.ts b/back/volume/src/pong/game/Games.ts index 8ce0bb3..3a8bd87 100644 --- a/back/volume/src/pong/game/Games.ts +++ b/back/volume/src/pong/game/Games.ts @@ -111,13 +111,16 @@ export class Games { socket: WebSocket, uuid: string, name: string - ): void { + ): boolean { + let succeeded: boolean = false const gameIndex: number | undefined = this.playerNameToGameIndex.get(nameToSpectate) if (gameIndex !== undefined) { this.playerNameToGameIndex.set(name, gameIndex) this.games[gameIndex].addSpectator(socket, uuid, name) + succeeded = true } + return succeeded } async leaveGame (name: string): Promise { diff --git a/back/volume/src/pong/pong.gateway.ts b/back/volume/src/pong/pong.gateway.ts index 5f707b3..cf1c451 100644 --- a/back/volume/src/pong/pong.gateway.ts +++ b/back/volume/src/pong/pong.gateway.ts @@ -190,8 +190,7 @@ export class PongGateway implements OnGatewayConnection, OnGatewayDisconnect { let succeeded: boolean = false const name: string | undefined = this.socketToPlayerName.get(client) if (name !== undefined) { - this.games.spectateGame(playerToSpectate.value, client, client.id, name) - succeeded = true + succeeded = this.games.spectateGame(playerToSpectate.value, client, client.id, name) } return { event: GAME_EVENTS.SPECTATE, data: succeeded } } diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index 08510f5..1c50f2c 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -184,8 +184,8 @@ let fakeUser = false; function impersonate() { const user = { - username: "test", - socketKey: "42", + username: usernameFake, + socketKey: ftIdFake, }; store.set(user); fakeUser = true; @@ -269,7 +269,7 @@ {/if} {#if fakemenu} - + {:else} diff --git a/front/volume/src/FakeLogin.svelte b/front/volume/src/FakeLogin.svelte index 6b2f4d6..a05f2b7 100644 --- a/front/volume/src/FakeLogin.svelte +++ b/front/volume/src/FakeLogin.svelte @@ -15,7 +15,7 @@ body: JSON.stringify({ ftId, username, - socketKey: "42", + socketKey: ftId, avatar: "no avatar", }), }); diff --git a/front/volume/src/components/Pong/Pong.svelte b/front/volume/src/components/Pong/Pong.svelte index 74c81a9..4ea52fd 100644 --- a/front/volume/src/components/Pong/Pong.svelte +++ b/front/volume/src/components/Pong/Pong.svelte @@ -95,9 +95,6 @@ } else if (event == GAME_EVENTS.SPECTATE) { if (data) { gamePlaying = true; - setInterval(() => { - updateGameInfo(); - }, 1000); } } else if (event == GAME_EVENTS.READY) { game.youAreReady = true;