Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] PINGPONG 메시지 예외 처리 #78

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<StockDto.RealTimeStockDto> stockInfoDtoList = parseStockInfo(data);
for (StockDto.RealTimeStockDto dto : stockInfoDtoList) {
Expand All @@ -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);
}
}

Expand Down