Skip to content

Commit

Permalink
fix: server 소켓 이벤트 전송 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
nowChae committed Nov 19, 2024
1 parent d6ded0d commit 354f863
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/server/src/module/game/game.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export class GameGateway implements OnGatewayConnection, OnGatewayDisconnect {
gameInfo.participantList.push(nickname);
this.redisService.set(`gameId=${pinCode}`, JSON.stringify(gameInfo));

this.server.to(pinCode).emit('nickname', gameInfo.participantList);
client.emit('nickname', gameInfo.participantList);
client.to(pinCode).emit('nickname', gameInfo.participantList);
}

@SubscribeMessage('nickname')
Expand All @@ -82,7 +83,8 @@ export class GameGateway implements OnGatewayConnection, OnGatewayDisconnect {

const gameInfo = JSON.parse(await this.redisService.get(`gameId=${pinCode}`));

this.server.to(pinCode).emit('nickname', gameInfo.participantList);
client.emit('nickname', gameInfo.participantList);
client.to(pinCode).emit('nickname', gameInfo.participantList);
}

@SubscribeMessage('show quiz')
Expand All @@ -101,7 +103,9 @@ export class GameGateway implements OnGatewayConnection, OnGatewayDisconnect {
// {id, content, choice[]}
const currentQuizData = quizData[currentOrder];

this.server.to(pinCode).emit('show quiz', currentQuizData);
// this.server.to(pinCode).emit('show quiz', currentQuizData);
client.emit('show quiz', currentQuizData);
client.to(pinCode).emit('show quiz', currentQuizData);

gameInfo.currentOrder += 1;
await this.redisService.set(`gameId=${pinCode}`, JSON.stringify(gameInfo));
Expand Down

0 comments on commit 354f863

Please sign in to comment.