|
5 | 5 | import io.f1.backend.domain.game.app.RoomService; |
6 | 6 | import io.f1.backend.domain.game.dto.MessageType; |
7 | 7 | import io.f1.backend.domain.game.dto.response.HeartbeatResponse; |
8 | | -import io.f1.backend.domain.user.dto.UserPrincipal; |
9 | 8 |
|
10 | 9 | import lombok.RequiredArgsConstructor; |
11 | 10 | import lombok.extern.slf4j.Slf4j; |
|
14 | 13 | import org.springframework.messaging.simp.user.SimpUser; |
15 | 14 | import org.springframework.messaging.simp.user.SimpUserRegistry; |
16 | 15 | import org.springframework.scheduling.annotation.Scheduled; |
17 | | -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
18 | 16 | import org.springframework.stereotype.Component; |
19 | 17 |
|
20 | | -import java.security.Principal; |
21 | 18 | import java.util.Map; |
22 | 19 | import java.util.concurrent.ConcurrentHashMap; |
23 | 20 |
|
@@ -61,25 +58,25 @@ private void handleSessionHeartbeat(SimpUser user, SimpSession session) { |
61 | 58 | new HeartbeatResponse(DIRECTION), |
62 | 59 | user.getName()); |
63 | 60 |
|
64 | | - //todo FE 개발 될때까지 주석 처리 |
65 | | -// missedPongCounter.merge(sessionId, 1, Integer::sum); |
66 | | -// int missedCnt = missedPongCounter.get(sessionId); |
67 | | -// |
68 | | -// /* max_missed_heartbeats 이상 pong 이 안왔을때 - disconnect 처리 */ |
69 | | -// if (missedCnt >= MAX_MISSED_HEARTBEATS) { |
70 | | -// |
71 | | -// Principal principal = user.getPrincipal(); |
72 | | -// |
73 | | -// if (principal instanceof UsernamePasswordAuthenticationToken token |
74 | | -// && token.getPrincipal() instanceof UserPrincipal userPrincipal) { |
75 | | -// |
76 | | -// Long userId = userPrincipal.getUserId(); |
77 | | -// Long roomId = roomService.getRoomIdByUserId(userId); |
78 | | -// |
79 | | -// roomService.disconnectOrExitRoom(roomId, userPrincipal); |
80 | | -// } |
81 | | -// missedPongCounter.remove(sessionId); |
82 | | -// } |
| 61 | + // todo FE 개발 될때까지 주석 처리 |
| 62 | + // missedPongCounter.merge(sessionId, 1, Integer::sum); |
| 63 | + // int missedCnt = missedPongCounter.get(sessionId); |
| 64 | + // |
| 65 | + // /* max_missed_heartbeats 이상 pong 이 안왔을때 - disconnect 처리 */ |
| 66 | + // if (missedCnt >= MAX_MISSED_HEARTBEATS) { |
| 67 | + // |
| 68 | + // Principal principal = user.getPrincipal(); |
| 69 | + // |
| 70 | + // if (principal instanceof UsernamePasswordAuthenticationToken token |
| 71 | + // && token.getPrincipal() instanceof UserPrincipal userPrincipal) { |
| 72 | + // |
| 73 | + // Long userId = userPrincipal.getUserId(); |
| 74 | + // Long roomId = roomService.getRoomIdByUserId(userId); |
| 75 | + // |
| 76 | + // roomService.disconnectOrExitRoom(roomId, userPrincipal); |
| 77 | + // } |
| 78 | + // missedPongCounter.remove(sessionId); |
| 79 | + // } |
83 | 80 | } |
84 | 81 |
|
85 | 82 | public void resetMissedPongCount(String sessionId) { |
|
0 commit comments