Skip to content

Commit

Permalink
fix: user update 한번에 하기
Browse files Browse the repository at this point in the history
  • Loading branch information
tomatoziyun committed Dec 27, 2023
1 parent 0852039 commit 8e3ffaa
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/game/game.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export class GameGateway implements OnGatewayConnection, OnGatewayDisconnect {

async handleConnection(@ConnectedSocket() client: Socket) {
const user = await this.authService.getUserFromSocket(client);
if (!user || !client.id || user.gameSocketId)
return client.disconnect();
if (!user || !client.id) return client.disconnect();
else if (user.gameSocketId) client.disconnect();

console.log(`${user.id} is connected to game socket {${client.id}}`);

Expand All @@ -92,6 +92,7 @@ export class GameGateway implements OnGatewayConnection, OnGatewayDisconnect {

await this.usersRepository.update(user.id, {
gameSocketId: null,
status: UserStatus.ONLINE,
});

const gameId = this.userIdToGameId.get(user.id);
Expand All @@ -116,9 +117,6 @@ export class GameGateway implements OnGatewayConnection, OnGatewayDisconnect {
}
}
this.userIdToClient.delete(user.id);
await this.usersRepository.update(user.id, {
status: UserStatus.ONLINE,
});
}

@SubscribeMessage('gameRequest')
Expand Down

0 comments on commit 8e3ffaa

Please sign in to comment.