@@ -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,29 +264,29 @@ 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
273273 public void reconnectSession (
274- Long roomId , String oldSessionId , String newSessionId , UserPrincipal principal ) {
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
280280 messageSender .send (
281- destination ,
282- MessageType .SYSTEM_NOTICE ,
283- ofPlayerEvent (principal .getUserNickname (), RoomEventType .RECONNECT ));
281+ destination ,
282+ MessageType .SYSTEM_NOTICE ,
283+ ofPlayerEvent (principal .getUserNickname (), RoomEventType .RECONNECT ));
284284
285285 if (room .isPlaying ()) {
286286 // todo 현재 round 및 타이머 ..
287287 // todo 랭킹 리스트
288288 messageSender .send (
289- destination , MessageType .GAME_START , toGameStartResponse (room .getQuestions ()));
289+ destination , MessageType .GAME_START , toGameStartResponse (room .getQuestions ()));
290290
291291 } else {
292292
@@ -296,7 +296,7 @@ public void reconnectSession(
296296 Quiz quiz = quizService .getQuizWithQuestionsById (quizId );
297297
298298 GameSettingResponse gameSettingResponse =
299- toGameSettingResponse (room .getGameSetting (), quiz );
299+ toGameSettingResponse (room .getGameSetting (), quiz );
300300
301301 PlayerListResponse playerListResponse = toPlayerListResponse (room );
302302
@@ -342,8 +342,8 @@ private Player createPlayer() {
342342
343343 private Room findRoom (Long roomId ) {
344344 return roomRepository
345- .findRoom (roomId )
346- .orElseThrow (() -> new CustomException (RoomErrorCode .ROOM_NOT_FOUND ));
345+ .findRoom (roomId )
346+ .orElseThrow (() -> new CustomException (RoomErrorCode .ROOM_NOT_FOUND ));
347347 }
348348
349349 private void removeRoom (Room room ) {
@@ -357,16 +357,16 @@ private void changeHost(Room room, String hostSessionId) {
357357 Map <String , Player > playerSessionMap = room .getPlayerSessionMap ();
358358
359359 Optional <String > nextHostSessionId =
360- playerSessionMap .entrySet ().stream ()
361- .filter (entry -> !entry .getKey ().equals (hostSessionId ))
362- .filter (entry -> entry .getValue ().getState () == ConnectionState .CONNECTED )
363- .map (Map .Entry ::getKey )
364- .findFirst ();
360+ playerSessionMap .entrySet ().stream ()
361+ .filter (entry -> !entry .getKey ().equals (hostSessionId ))
362+ .filter (entry -> entry .getValue ().getState () == ConnectionState .CONNECTED )
363+ .map (Map .Entry ::getKey )
364+ .findFirst ();
365365
366366 Player nextHost =
367- playerSessionMap .get (
368- nextHostSessionId .orElseThrow (
369- () -> new CustomException (RoomErrorCode .SOCKET_SESSION_NOT_FOUND )));
367+ playerSessionMap .get (
368+ nextHostSessionId .orElseThrow (
369+ () -> new CustomException (RoomErrorCode .SOCKET_SESSION_NOT_FOUND )));
370370
371371 room .updateHost (nextHost );
372372 log .info ("user_id:{} 방장 변경 완료 " , nextHost .getId ());
0 commit comments