Skip to content

Commit f25c170

Browse files
committed
♻️ 충돌 해결
1 parent 18a6cb5 commit f25c170

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

backend/src/main/java/io/f1/backend/domain/game/websocket/GameSocketController.java

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package io.f1.backend.domain.game.websocket;
22

3+
import static io.f1.backend.domain.game.websocket.WebSocketUtils.getSessionId;
4+
import static io.f1.backend.domain.game.websocket.WebSocketUtils.getSessionUser;
5+
36
import io.f1.backend.domain.game.app.GameService;
47
import io.f1.backend.domain.game.app.RoomService;
58
import io.f1.backend.domain.game.dto.ChatMessage;
6-
import io.f1.backend.domain.game.dto.MessageType;
79
import io.f1.backend.domain.game.dto.request.DefaultWebSocketRequest;
8-
import io.f1.backend.domain.game.dto.response.GameStartResponse;
910
import io.f1.backend.domain.user.dto.UserPrincipal;
1011
import lombok.RequiredArgsConstructor;
1112
import org.springframework.messaging.Message;
@@ -42,20 +43,12 @@ public void exitRoom(@DestinationVariable Long roomId, Message<?> message) {
4243
}
4344

4445
@MessageMapping("/room/start/{roomId}")
45-
public void gameStart(
46-
@DestinationVariable Long roomId,
47-
Message<DefaultWebSocketRequest<GameStartRequest>> message) {
4846
public void gameStart(@DestinationVariable Long roomId, Message<?> message) {
4947

50-
GameStartResponse gameStartResponse =
51-
gameService.gameStart(roomId, message.getPayload().getMessage());
5248
UserPrincipal principal = getSessionUser(message);
5349

54-
GameStartResponse gameStartResponse = gameService.gameStart(roomId, principal);
50+
gameService.gameStart(roomId,principal);
5551

56-
String destination = getDestination(roomId);
57-
58-
messageSender.send(destination, MessageType.GAME_START, gameStartResponse);
5952
}
6053

6154
@MessageMapping("room/chat/{roomId}")
@@ -72,17 +65,6 @@ public void playerReady(@DestinationVariable Long roomId, Message<?> message) {
7265
roomService.handlePlayerReady(roomId, getSessionId(message));
7366
}
7467

75-
private static String getSessionId(Message<?> message) {
76-
StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
77-
return accessor.getSessionId();
78-
}
79-
80-
private static UserPrincipal getSessionUser(Message<?> message) {
81-
StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
82-
Authentication auth = (Authentication) accessor.getUser();
83-
return (UserPrincipal) auth.getPrincipal();
84-
}
85-
8668
//todo 삭제
8769
private String getDestination(Long roomId) {
8870
return "/sub/room/" + roomId;

0 commit comments

Comments
 (0)