diff --git a/backend/src/events/events.gateway.ts b/backend/src/events/events.gateway.ts index 2fbb8404..3c12f521 100644 --- a/backend/src/events/events.gateway.ts +++ b/backend/src/events/events.gateway.ts @@ -139,8 +139,11 @@ export class EventsGateway implements OnGatewayDisconnect { user, }); this.emitUpdateStatus(client, 'joined-as-player'); - if (Object.keys(this.players[gameId]).length == 2) { - this.emitUpdateStatus(client, 'ready'); + const opponent = getOpponent(this.players, gameId, client.id); + if (opponent) { + this.emitUpdateStatus(client, 'ready', { + user: this.users[opponent], + }); } this.lostPoints[client.id] = 0; return; diff --git a/frontend/app/pong/[id]/PongBoard.tsx b/frontend/app/pong/[id]/PongBoard.tsx index fc92fa1c..af703653 100644 --- a/frontend/app/pong/[id]/PongBoard.tsx +++ b/frontend/app/pong/[id]/PongBoard.tsx @@ -180,6 +180,13 @@ function PongBoard({ id }: PongBoardProps) { }); } break; + case "ready": { + { + const { user } = payload; + setRightPlayer(user); + } + break; + } } }, [currentUser, setUserMode, getGame, getPlayerSetterFromPlayerNumber],