@@ -117,7 +117,7 @@ public void enterRoom(RoomValidationRequest request) {
117117 }
118118
119119 if (room .getRoomSetting ().locked ()
120- && !room .getRoomSetting ().password ().equals (request .password ())) {
120+ && !room .getRoomSetting ().password ().equals (request .password ())) {
121121 throw new CustomException (RoomErrorCode .WRONG_PASSWORD );
122122 }
123123
@@ -139,12 +139,12 @@ public void initializeRoomSocket(Long roomId, String sessionId, UserPrincipal pr
139139 Quiz quiz = quizService .getQuizWithQuestionsById (quizId );
140140
141141 GameSettingResponse gameSettingResponse =
142- toGameSettingResponse (room .getGameSetting (), quiz );
142+ toGameSettingResponse (room .getGameSetting (), quiz );
143143
144144 PlayerListResponse playerListResponse = toPlayerListResponse (room );
145145
146146 SystemNoticeResponse systemNoticeResponse =
147- ofPlayerEvent (player .getNickname (), RoomEventType .ENTER );
147+ ofPlayerEvent (player .getNickname (), RoomEventType .ENTER );
148148
149149 String destination = getDestination (roomId );
150150
@@ -180,7 +180,7 @@ public void exitRoom(Long roomId, String sessionId, UserPrincipal principal) {
180180 removePlayer (room , sessionId , removePlayer );
181181
182182 SystemNoticeResponse systemNoticeResponse =
183- ofPlayerEvent (removePlayer .nickname , RoomEventType .EXIT );
183+ ofPlayerEvent (removePlayer .nickname , RoomEventType .EXIT );
184184
185185 PlayerListResponse playerListResponse = toPlayerListResponse (room );
186186
@@ -191,9 +191,9 @@ public void exitRoom(Long roomId, String sessionId, UserPrincipal principal) {
191191
192192 public void handlePlayerReady (Long roomId , String sessionId ) {
193193 Player player =
194- roomRepository
195- .findPlayerInRoomBySessionId (roomId , sessionId )
196- .orElseThrow (() -> new CustomException (RoomErrorCode .PLAYER_NOT_FOUND ));
194+ roomRepository
195+ .findPlayerInRoomBySessionId (roomId , sessionId )
196+ .orElseThrow (() -> new CustomException (RoomErrorCode .PLAYER_NOT_FOUND ));
197197
198198 player .toggleReady ();
199199
@@ -207,15 +207,15 @@ public void handlePlayerReady(Long roomId, String sessionId) {
207207 public RoomListResponse getAllRooms () {
208208 List <Room > rooms = roomRepository .findAll ();
209209 List <RoomResponse > roomResponses =
210- rooms .stream ()
211- .map (
212- room -> {
213- Long quizId = room .getGameSetting ().getQuizId ();
214- Quiz quiz = quizService .getQuizWithQuestionsById (quizId );
215-
216- return toRoomResponse (room , quiz );
217- })
218- .toList ();
210+ rooms .stream ()
211+ .map (
212+ room -> {
213+ Long quizId = room .getGameSetting ().getQuizId ();
214+ Quiz quiz = quizService .getQuizWithQuestionsById (quizId );
215+
216+ return toRoomResponse (room , quiz );
217+ })
218+ .toList ();
219219 return new RoomListResponse (roomResponses );
220220 }
221221
@@ -240,14 +240,14 @@ public void chat(Long roomId, String sessionId, ChatMessage chatMessage) {
240240 room .increasePlayerCorrectCount (sessionId );
241241
242242 messageSender .send (
243- destination ,
244- MessageType .QUESTION_RESULT ,
245- toQuestionResultResponse (chatMessage .nickname (), answer ));
243+ destination ,
244+ MessageType .QUESTION_RESULT ,
245+ toQuestionResultResponse (chatMessage .nickname (), answer ));
246246 messageSender .send (destination , MessageType .RANK_UPDATE , toRankUpdateResponse (room ));
247247 messageSender .send (
248- destination ,
249- MessageType .SYSTEM_NOTICE ,
250- ofPlayerEvent (chatMessage .nickname (), RoomEventType .CORRECT_ANSWER ));
248+ destination ,
249+ MessageType .SYSTEM_NOTICE ,
250+ ofPlayerEvent (chatMessage .nickname (), RoomEventType .CORRECT_ANSWER ));
251251
252252 timerService .cancelTimer (room );
253253
@@ -262,29 +262,29 @@ public void chat(Long roomId, String sessionId, ChatMessage chatMessage) {
262262 // 타이머 추가하기
263263 timerService .startTimer (room , CONTINUE_DELAY );
264264 messageSender .send (
265- destination ,
266- MessageType .QUESTION_START ,
267- toQuestionStartResponse (room , CONTINUE_DELAY ));
265+ destination ,
266+ MessageType .QUESTION_START ,
267+ toQuestionStartResponse (room , CONTINUE_DELAY ));
268268 }
269269 }
270270
271271 public void reconnectSession (
272- Long roomId , String oldSessionId , String newSessionId , UserPrincipal principal ) {
272+ Long roomId , String oldSessionId , String newSessionId , UserPrincipal principal ) {
273273 Room room = findRoom (roomId );
274274 room .reconnectSession (oldSessionId , newSessionId );
275275
276276 String destination = getDestination (roomId );
277277
278278 messageSender .send (
279- destination ,
280- MessageType .SYSTEM_NOTICE ,
281- ofPlayerEvent (principal .getUserNickname (), RoomEventType .RECONNECT ));
279+ destination ,
280+ MessageType .SYSTEM_NOTICE ,
281+ ofPlayerEvent (principal .getUserNickname (), RoomEventType .RECONNECT ));
282282
283283 if (room .isPlaying ()) {
284284 // todo 현재 round 및 타이머 ..
285285 // todo 랭킹 리스트
286286 messageSender .send (
287- destination , MessageType .GAME_START , toGameStartResponse (room .getQuestions ()));
287+ destination , MessageType .GAME_START , toGameStartResponse (room .getQuestions ()));
288288
289289 } else {
290290
@@ -294,7 +294,7 @@ public void reconnectSession(
294294 Quiz quiz = quizService .getQuizWithQuestionsById (quizId );
295295
296296 GameSettingResponse gameSettingResponse =
297- toGameSettingResponse (room .getGameSetting (), quiz );
297+ toGameSettingResponse (room .getGameSetting (), quiz );
298298
299299 PlayerListResponse playerListResponse = toPlayerListResponse (room );
300300
@@ -340,8 +340,8 @@ private Player createPlayer() {
340340
341341 private Room findRoom (Long roomId ) {
342342 return roomRepository
343- .findRoom (roomId )
344- .orElseThrow (() -> new CustomException (RoomErrorCode .ROOM_NOT_FOUND ));
343+ .findRoom (roomId )
344+ .orElseThrow (() -> new CustomException (RoomErrorCode .ROOM_NOT_FOUND ));
345345 }
346346
347347 private void removeRoom (Room room ) {
@@ -355,16 +355,16 @@ private void changeHost(Room room, String hostSessionId) {
355355 Map <String , Player > playerSessionMap = room .getPlayerSessionMap ();
356356
357357 Optional <String > nextHostSessionId =
358- playerSessionMap .entrySet ().stream ()
359- .filter (entry -> !entry .getKey ().equals (hostSessionId ))
360- .filter (entry -> entry .getValue ().getState () == ConnectionState .CONNECTED )
361- .map (Map .Entry ::getKey )
362- .findFirst ();
358+ playerSessionMap .entrySet ().stream ()
359+ .filter (entry -> !entry .getKey ().equals (hostSessionId ))
360+ .filter (entry -> entry .getValue ().getState () == ConnectionState .CONNECTED )
361+ .map (Map .Entry ::getKey )
362+ .findFirst ();
363363
364364 Player nextHost =
365- playerSessionMap .get (
366- nextHostSessionId .orElseThrow (
367- () -> new CustomException (RoomErrorCode .SOCKET_SESSION_NOT_FOUND )));
365+ playerSessionMap .get (
366+ nextHostSessionId .orElseThrow (
367+ () -> new CustomException (RoomErrorCode .SOCKET_SESSION_NOT_FOUND )));
368368
369369 room .updateHost (nextHost );
370370 log .info ("user_id:{} 방장 변경 완료 " , nextHost .getId ());
0 commit comments