From 963401bd056082165b5299cacb2ae43052f86416 Mon Sep 17 00:00:00 2001 From: price126 Date: Thu, 28 Nov 2024 16:23:37 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20PINGPONG=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=20=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stocksignal/websocket/WebSocketHandler.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/back/src/main/java/com/thered/stocksignal/websocket/WebSocketHandler.java b/back/src/main/java/com/thered/stocksignal/websocket/WebSocketHandler.java index cde3b99..224281a 100644 --- a/back/src/main/java/com/thered/stocksignal/websocket/WebSocketHandler.java +++ b/back/src/main/java/com/thered/stocksignal/websocket/WebSocketHandler.java @@ -74,6 +74,7 @@ protected void handleTextMessage(WebSocketSession clientSession, TextMessage mes String token = dto.getToken(); Long userId = userAccountService.getUserIdFromToken(token); + userAccountService.refreshKisSocketKey(userId); String companyName = dto.getCompanyName(); String companyCode = null; @@ -236,6 +237,17 @@ private void handleResponse(String response, Long userId, String searchName) { String[] parts = response.split("\\|"); String[] data = parts[parts.length - 1].split("\\^"); + // PINGPONG 응답 처리 + if (response.contains("\"tr_id\":\"PINGPONG\"")) { + try{ + userSessions.get(userId).getClientSession().sendMessage(new TextMessage("현재는 장 마감되었습니다.")); + }catch (IOException e){ + log.info("장 마감 메시지를 보내는 중 예외가 발생했습니다. {}", e.getMessage()); + return; + } + return; + } + if (parts.length >= 4) { List stockInfoDtoList = parseStockInfo(data); for (StockDto.RealTimeStockDto dto : stockInfoDtoList) { @@ -246,7 +258,8 @@ private void handleResponse(String response, Long userId, String searchName) { scenarioTrade.checkAutoTrade(userId, dto); } } else { - throw new RuntimeException("한투에서 온 응답이 예상된 방식과 다릅니다 : " + response); // 초당 거래건수 초과 등 + // SUBSCRIBED, 초당 거래건수 초과 등 응답양식은 exception이지만 서비스는 계속 이어져야 하는 경우 + log.info("한투에서 온 응답이 예상된 방식과 다릅니다 : {}", response); } }