3838import io .f1 .backend .domain .user .dto .UserPrincipal ;
3939import io .f1 .backend .global .exception .CustomException ;
4040import io .f1 .backend .global .exception .errorcode .RoomErrorCode ;
41+
42+ import lombok .RequiredArgsConstructor ;
43+ import lombok .extern .slf4j .Slf4j ;
44+
45+ import org .springframework .context .ApplicationEventPublisher ;
46+ import org .springframework .stereotype .Service ;
47+
4148import java .util .List ;
4249import java .util .Map ;
4350import java .util .Optional ;
4451import java .util .concurrent .ConcurrentHashMap ;
4552import java .util .concurrent .atomic .AtomicLong ;
46- import lombok .RequiredArgsConstructor ;
47- import lombok .extern .slf4j .Slf4j ;
48- import org .springframework .context .ApplicationEventPublisher ;
49- import org .springframework .stereotype .Service ;
5053
5154@ Slf4j
5255@ Service
@@ -113,8 +116,7 @@ public void enterRoom(RoomValidationRequest request) {
113116 }
114117 }
115118
116- public void initializeRoomSocket (
117- Long roomId , String sessionId , UserPrincipal principal ) {
119+ public void initializeRoomSocket (Long roomId , String sessionId , UserPrincipal principal ) {
118120
119121 Room room = findRoom (roomId );
120122
@@ -149,14 +151,10 @@ public void initializeRoomSocket(
149151
150152 String destination = getDestination (roomId );
151153
152- messageSender .send (
153- destination , MessageType .ROOM_SETTING , roomSettingResponse );
154- messageSender .send (
155- destination , MessageType .GAME_SETTING , gameSettingResponse );
156- messageSender .send (
157- destination , MessageType .PLAYER_LIST , playerListResponse );
158- messageSender .send (
159- destination , MessageType .SYSTEM_NOTICE , systemNoticeResponse );
154+ messageSender .send (destination , MessageType .ROOM_SETTING , roomSettingResponse );
155+ messageSender .send (destination , MessageType .GAME_SETTING , gameSettingResponse );
156+ messageSender .send (destination , MessageType .PLAYER_LIST , playerListResponse );
157+ messageSender .send (destination , MessageType .SYSTEM_NOTICE , systemNoticeResponse );
160158 }
161159
162160 public void exitRoom (Long roomId , String sessionId , UserPrincipal principal ) {
@@ -189,11 +187,8 @@ public void exitRoom(Long roomId, String sessionId, UserPrincipal principal) {
189187
190188 String destination = getDestination (roomId );
191189
192- messageSender .send (
193- destination , MessageType .PLAYER_LIST , playerListResponse );
194- messageSender .send (
195- destination , MessageType .SYSTEM_NOTICE , systemNoticeResponse );
196-
190+ messageSender .send (destination , MessageType .PLAYER_LIST , playerListResponse );
191+ messageSender .send (destination , MessageType .SYSTEM_NOTICE , systemNoticeResponse );
197192 }
198193 }
199194
@@ -210,7 +205,6 @@ public void handlePlayerReady(Long roomId, String sessionId) {
210205 String destination = getDestination (roomId );
211206
212207 messageSender .send (destination , MessageType .PLAYER_LIST , toPlayerListResponse (room ));
213-
214208 }
215209
216210 public RoomListResponse getAllRooms () {
@@ -248,11 +242,13 @@ public void chat(Long roomId, String sessionId, ChatMessage chatMessage) {
248242 room .increasePlayerCorrectCount (sessionId );
249243
250244 messageSender .send (
251- destination , MessageType .QUESTION_RESULT ,
245+ destination ,
246+ MessageType .QUESTION_RESULT ,
252247 toQuestionResultResponse (currentQuestion .getId (), chatMessage , answer ));
253248 messageSender .send (destination , MessageType .RANK_UPDATE , toRankUpdateResponse (room ));
254249 messageSender .send (
255- destination , MessageType .SYSTEM_NOTICE ,
250+ destination ,
251+ MessageType .SYSTEM_NOTICE ,
256252 ofPlayerEvent (chatMessage .nickname (), RoomEventType .ENTER ));
257253 }
258254 }
@@ -314,7 +310,6 @@ private void removePlayer(Room room, String sessionId, Player removePlayer) {
314310 room .removeSessionId (sessionId );
315311 }
316312
317-
318313 private String getDestination (Long roomId ) {
319314 return "/sub/room/" + roomId ;
320315 }
0 commit comments