Skip to content

Commit 31a3b88

Browse files
committed
♻️ 정상로직에 대한 처리
1 parent 928b61a commit 31a3b88

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

backend/src/main/java/io/f1/backend/domain/game/store/UserRoomRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ public void removeUser(Long userId, Long roomId) {
2323
userRoomMap.remove(userId, roomId);
2424
}
2525

26+
public boolean isUserInAnyRoom(Long userId) {
27+
return userRoomMap.containsKey(userId);
28+
}
29+
2630
}

backend/src/main/java/io/f1/backend/domain/game/websocket/eventlistener/WebsocketEventListener.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ public void handleDisconnectedListener(SessionDisconnectEvent event) {
2929

3030
Long userId = principal.getUserId();
3131

32+
/* 정상 로직 */
33+
if(!roomService.isUserInAnyRoom(userId)) {
34+
return;
35+
}
36+
3237
Long roomId = roomService.changeConnectedStatus(userId,ConnectionState.DISCONNECTED);
3338

3439
taskManager.scheduleDisconnectTask(userId , () -> {
3540
if(ConnectionState.DISCONNECTED.equals(roomService.getPlayerState(userId,roomId))) {
3641
roomService.exitIfNotPlaying(roomId,principal);
37-
roomService.removeUserRepository(userId, roomId);
3842
}
3943
});
4044
}

0 commit comments

Comments
 (0)