11package 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+
36import io .f1 .backend .domain .game .app .GameService ;
47import io .f1 .backend .domain .game .app .RoomService ;
58import io .f1 .backend .domain .game .dto .ChatMessage ;
6- import io .f1 .backend .domain .game .dto .MessageType ;
79import io .f1 .backend .domain .game .dto .request .DefaultWebSocketRequest ;
8- import io .f1 .backend .domain .game .dto .response .GameStartResponse ;
910import io .f1 .backend .domain .user .dto .UserPrincipal ;
1011import lombok .RequiredArgsConstructor ;
1112import 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