Skip to content

Commit 37c7a65

Browse files
committed
♻️ refactor : getDestination() util 메서드로 분리
1 parent a59060d commit 37c7a65

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

backend/src/main/java/io/f1/backend/domain/game/app/GameService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.f1.backend.domain.game.app;
22

33
import static io.f1.backend.domain.game.mapper.RoomMapper.toQuestionStartResponse;
4+
import static io.f1.backend.domain.game.websocket.WebSocketUtils.getDestination;
45
import static io.f1.backend.domain.quiz.mapper.QuizMapper.toGameStartResponse;
56

67
import io.f1.backend.domain.game.dto.MessageType;
@@ -96,8 +97,4 @@ private List<Question> prepareQuestions(Room room, Quiz quiz) {
9697
Integer round = room.getGameSetting().getRound();
9798
return quizService.getRandomQuestionsWithoutAnswer(quizId, round);
9899
}
99-
100-
private String getDestination(Long roomId) {
101-
return "/sub/room/" + roomId;
102-
}
103100
}

backend/src/main/java/io/f1/backend/domain/game/app/RoomService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import static io.f1.backend.domain.game.mapper.RoomMapper.toRoomResponse;
1111
import static io.f1.backend.domain.game.mapper.RoomMapper.toRoomSetting;
1212
import static io.f1.backend.domain.game.mapper.RoomMapper.toRoomSettingResponse;
13+
import static io.f1.backend.domain.game.websocket.WebSocketUtils.getDestination;
1314
import static io.f1.backend.global.util.SecurityUtils.getCurrentUserId;
1415
import static io.f1.backend.global.util.SecurityUtils.getCurrentUserNickname;
1516

@@ -333,7 +334,4 @@ private void removePlayer(Room room, String sessionId, Player removePlayer) {
333334
room.removeSessionId(sessionId);
334335
}
335336

336-
private String getDestination(Long roomId) {
337-
return "/sub/room/" + roomId;
338-
}
339337
}

backend/src/main/java/io/f1/backend/domain/game/app/TimerService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static io.f1.backend.domain.game.mapper.RoomMapper.ofPlayerEvent;
44
import static io.f1.backend.domain.game.mapper.RoomMapper.toQuestionResultResponse;
55
import static io.f1.backend.domain.game.mapper.RoomMapper.toQuestionStartResponse;
6+
import static io.f1.backend.domain.game.websocket.WebSocketUtils.getDestination;
67

78
import io.f1.backend.domain.game.dto.MessageType;
89
import io.f1.backend.domain.game.dto.RoomEventType;
@@ -85,8 +86,4 @@ public void cancelTimer(Room room) {
8586
timer.cancel(false);
8687
}
8788
}
88-
89-
private String getDestination(Long roomId) {
90-
return "/sub/room/" + roomId;
91-
}
9289
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ public static UserPrincipal getSessionUser(Message<?> message) {
1818
Authentication auth = (Authentication) accessor.getUser();
1919
return (UserPrincipal) auth.getPrincipal();
2020
}
21+
22+
public static String getDestination(Long roomId) {
23+
return "/sub/room/" + roomId;
24+
}
2125
}

0 commit comments

Comments
 (0)