|
4 | 4 | import com.mbtips.common.constant.Constant; |
5 | 5 | import com.mbtips.common.exception.CustomException; |
6 | 6 | import com.mbtips.domain.openChat.exception.OpenChatException; |
| 7 | +import com.mbtips.openChat.application.dto.OpenChatDto; |
7 | 8 | import com.mbtips.openChat.application.dto.OpenChatMessageDto; |
8 | 9 | import com.mbtips.openChat.application.service.OpenChatMessageService; |
9 | 10 | import lombok.RequiredArgsConstructor; |
@@ -51,9 +52,8 @@ public void afterConnectionEstablished(WebSocketSession session) throws IOExcept |
51 | 52 | Map<String, String> queryParamMap = this.parseQueryParam(query); |
52 | 53 | long openChatId = Long.parseLong(queryParamMap.get(OPEN_CHAT_ID)); |
53 | 54 | if (this.checkNickname(openChatId, queryParamMap.get(NICKNAME))) { |
54 | | - String string = OpenChatException.DUPLICATED_NICKNAME.getMessage(); |
55 | | - byte[] bytes = string.getBytes(); |
56 | | - session.sendMessage(new TextMessage(bytes)); |
| 55 | + OpenChatMessageDto openChatMessageDto = new OpenChatMessageDto(2, null, OpenChatException.DUPLICATED_NICKNAME.getMessage(), openChatId); |
| 56 | + session.sendMessage(new TextMessage(objectMapper.writeValueAsString(openChatMessageDto))); |
57 | 57 | throw new CustomException(OpenChatException.DUPLICATED_NICKNAME); |
58 | 58 | } |
59 | 59 |
|
@@ -113,6 +113,7 @@ public void afterConnectionClosed(WebSocketSession session, CloseStatus status) |
113 | 113 | private Map<String, String> parseQueryParam(String query) { |
114 | 114 | HashMap<String, String> queryParamMap = new HashMap<>(); |
115 | 115 | String[] pairs = query.split("&"); |
| 116 | + log.info("parseQueryParam.pairs: {}", Arrays.toString(pairs)); |
116 | 117 | Arrays.stream(pairs).forEach(pair -> { |
117 | 118 | String[] kv = pair.split("=", 2); |
118 | 119 | if (kv.length == 2) { |
|
0 commit comments