@@ -119,7 +119,7 @@ public void enterRoom(RoomValidationRequest request) {
119119 }
120120
121121 if (room .getRoomSetting ().locked ()
122- && !room .getRoomSetting ().password ().equals (request .password ())) {
122+ && !room .getRoomSetting ().password ().equals (request .password ())) {
123123 throw new CustomException (RoomErrorCode .WRONG_PASSWORD );
124124 }
125125
@@ -141,12 +141,12 @@ public void initializeRoomSocket(Long roomId, String sessionId, UserPrincipal pr
141141 Quiz quiz = quizService .getQuizWithQuestionsById (quizId );
142142
143143 GameSettingResponse gameSettingResponse =
144- toGameSettingResponse (room .getGameSetting (), quiz );
144+ toGameSettingResponse (room .getGameSetting (), quiz );
145145
146146 PlayerListResponse playerListResponse = toPlayerListResponse (room );
147147
148148 SystemNoticeResponse systemNoticeResponse =
149- ofPlayerEvent (player .getNickname (), RoomEventType .ENTER );
149+ ofPlayerEvent (player .getNickname (), RoomEventType .ENTER );
150150
151151 String destination = getDestination (roomId );
152152
@@ -182,7 +182,7 @@ public void exitRoom(Long roomId, String sessionId, UserPrincipal principal) {
182182 removePlayer (room , sessionId , removePlayer );
183183
184184 SystemNoticeResponse systemNoticeResponse =
185- ofPlayerEvent (removePlayer .nickname , RoomEventType .EXIT );
185+ ofPlayerEvent (removePlayer .nickname , RoomEventType .EXIT );
186186
187187 PlayerListResponse playerListResponse = toPlayerListResponse (room );
188188
@@ -193,9 +193,9 @@ public void exitRoom(Long roomId, String sessionId, UserPrincipal principal) {
193193
194194 public void handlePlayerReady (Long roomId , String sessionId ) {
195195 Player player =
196- roomRepository
197- .findPlayerInRoomBySessionId (roomId , sessionId )
198- .orElseThrow (() -> new CustomException (RoomErrorCode .PLAYER_NOT_FOUND ));
196+ roomRepository
197+ .findPlayerInRoomBySessionId (roomId , sessionId )
198+ .orElseThrow (() -> new CustomException (RoomErrorCode .PLAYER_NOT_FOUND ));
199199
200200 player .toggleReady ();
201201
@@ -209,15 +209,15 @@ public void handlePlayerReady(Long roomId, String sessionId) {
209209 public RoomListResponse getAllRooms () {
210210 List <Room > rooms = roomRepository .findAll ();
211211 List <RoomResponse > roomResponses =
212- rooms .stream ()
213- .map (
214- room -> {
215- Long quizId = room .getGameSetting ().getQuizId ();
216- Quiz quiz = quizService .getQuizWithQuestionsById (quizId );
217-
218- return toRoomResponse (room , quiz );
219- })
220- .toList ();
212+ rooms .stream ()
213+ .map (
214+ room -> {
215+ Long quizId = room .getGameSetting ().getQuizId ();
216+ Quiz quiz = quizService .getQuizWithQuestionsById (quizId );
217+
218+ return toRoomResponse (room , quiz );
219+ })
220+ .toList ();
221221 return new RoomListResponse (roomResponses );
222222 }
223223
@@ -242,14 +242,14 @@ public void chat(Long roomId, String sessionId, ChatMessage chatMessage) {
242242 room .increasePlayerCorrectCount (sessionId );
243243
244244 messageSender .send (
245- destination ,
246- MessageType .QUESTION_RESULT ,
247- toQuestionResultResponse (chatMessage .nickname (), answer ));
245+ destination ,
246+ MessageType .QUESTION_RESULT ,
247+ toQuestionResultResponse (chatMessage .nickname (), answer ));
248248 messageSender .send (destination , MessageType .RANK_UPDATE , toRankUpdateResponse (room ));
249249 messageSender .send (
250- destination ,
251- MessageType .SYSTEM_NOTICE ,
252- ofPlayerEvent (chatMessage .nickname (), RoomEventType .CORRECT_ANSWER ));
250+ destination ,
251+ MessageType .SYSTEM_NOTICE ,
252+ ofPlayerEvent (chatMessage .nickname (), RoomEventType .CORRECT_ANSWER ));
253253
254254 timerService .cancelTimer (room );
255255
@@ -264,50 +264,46 @@ public void chat(Long roomId, String sessionId, ChatMessage chatMessage) {
264264 // 타이머 추가하기
265265 timerService .startTimer (room , CONTINUE_DELAY );
266266 messageSender .send (
267- destination ,
268- MessageType .QUESTION_START ,
269- toQuestionStartResponse (room , CONTINUE_DELAY ));
267+ destination ,
268+ MessageType .QUESTION_START ,
269+ toQuestionStartResponse (room , CONTINUE_DELAY ));
270270 }
271271 }
272272
273- public void reconnectSession (Long roomId , String oldSessionId , String newSessionId ,
274- UserPrincipal principal ) {
273+ public void reconnectSession (
274+ Long roomId , String oldSessionId , String newSessionId , UserPrincipal principal ) {
275275 Room room = findRoom (roomId );
276276 room .reconnectSession (oldSessionId , newSessionId );
277277
278278 String destination = getDestination (roomId );
279279
280-
281-
282-
283280 messageSender .send (
284- destination ,
285- MessageType .SYSTEM_NOTICE ,
286- ofPlayerEvent (principal .getUserNickname (), RoomEventType .RECONNECT ));
281+ destination ,
282+ MessageType .SYSTEM_NOTICE ,
283+ ofPlayerEvent (principal .getUserNickname (), RoomEventType .RECONNECT ));
287284
288285 if (room .isPlaying ()) {
289- //todo 현재 round 및 타이머 ..
290- //todo 랭킹 리스트
291- messageSender .send (destination , MessageType .GAME_START , toGameStartResponse (room .getQuestions ()));
286+ // todo 현재 round 및 타이머 ..
287+ // todo 랭킹 리스트
288+ messageSender .send (
289+ destination , MessageType .GAME_START , toGameStartResponse (room .getQuestions ()));
292290
293- }else {
291+ } else {
294292
295293 RoomSettingResponse roomSettingResponse = toRoomSettingResponse (room );
296294
297295 Long quizId = room .getGameSetting ().getQuizId ();
298296 Quiz quiz = quizService .getQuizWithQuestionsById (quizId );
299297
300298 GameSettingResponse gameSettingResponse =
301- toGameSettingResponse (room .getGameSetting (), quiz );
299+ toGameSettingResponse (room .getGameSetting (), quiz );
302300
303301 PlayerListResponse playerListResponse = toPlayerListResponse (room );
304302
305303 messageSender .send (destination , MessageType .ROOM_SETTING , roomSettingResponse );
306304 messageSender .send (destination , MessageType .GAME_SETTING , gameSettingResponse );
307305 messageSender .send (destination , MessageType .PLAYER_LIST , playerListResponse );
308306 }
309-
310-
311307 }
312308
313309 public void changeConnectedStatus (Long roomId , String sessionId , ConnectionState newState ) {
@@ -327,7 +323,6 @@ public void exitIfNotPlaying(Long roomId, String sessionId, UserPrincipal princi
327323 }
328324 }
329325
330-
331326 private Player getRemovePlayer (Room room , String sessionId , UserPrincipal principal ) {
332327 Player removePlayer = room .getPlayerSessionMap ().get (sessionId );
333328 if (removePlayer == null ) {
@@ -347,8 +342,8 @@ private Player createPlayer() {
347342
348343 private Room findRoom (Long roomId ) {
349344 return roomRepository
350- .findRoom (roomId )
351- .orElseThrow (() -> new CustomException (RoomErrorCode .ROOM_NOT_FOUND ));
345+ .findRoom (roomId )
346+ .orElseThrow (() -> new CustomException (RoomErrorCode .ROOM_NOT_FOUND ));
352347 }
353348
354349 private boolean isLastPlayer (Room room , String sessionId ) {
@@ -367,14 +362,14 @@ private void changeHost(Room room, String hostSessionId) {
367362 Map <String , Player > playerSessionMap = room .getPlayerSessionMap ();
368363
369364 Optional <String > nextHostSessionId =
370- playerSessionMap .keySet ().stream ()
371- .filter (key -> !key .equals (hostSessionId ))
372- .findFirst ();
365+ playerSessionMap .keySet ().stream ()
366+ .filter (key -> !key .equals (hostSessionId ))
367+ .findFirst ();
373368
374369 Player nextHost =
375- playerSessionMap .get (
376- nextHostSessionId .orElseThrow (
377- () -> new CustomException (RoomErrorCode .SOCKET_SESSION_NOT_FOUND )));
370+ playerSessionMap .get (
371+ nextHostSessionId .orElseThrow (
372+ () -> new CustomException (RoomErrorCode .SOCKET_SESSION_NOT_FOUND )));
378373
379374 room .updateHost (nextHost );
380375 log .info ("user_id:{} 방장 변경 완료 " , nextHost .getId ());
0 commit comments