Skip to content

Commit 0d4f2aa

Browse files
authored
deploy 1.8.2
배포 1.8.2
2 parents bcd37e0 + 57a1645 commit 0d4f2aa

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/main/java/com/day_walk/backend/domain/chat/service/SseEmitters.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public SseEmitter add(UUID userId) {
4343
SseEmitter old = emitters.remove(userId);
4444

4545
if (old != null) {
46-
old.complete();
46+
old.completeWithError(new CustomException(ErrorCode.SSE_CONNECTION_ERROR));
4747
}
4848

4949
SseEmitter emitter = new SseEmitter(30_000L);
@@ -107,4 +107,20 @@ public void sendToClient(UUID userId, String question, GetChatByMlDto getChatByM
107107
}
108108
}
109109
}
110+
111+
public void sendToClientDone(UUID userId) {
112+
SseEmitter emitter = emitters.get(userId);
113+
114+
if (emitter != null) {
115+
try {
116+
emitter.send(SseEmitter.event()
117+
.name("chatbot")
118+
.data("[DONE]"));
119+
120+
emitter.complete();
121+
} catch (IOException e) {
122+
throw new CustomException(ErrorCode.SSE_CONNECTION_ERROR);
123+
}
124+
}
125+
}
110126
}

src/main/java/com/day_walk/backend/global/config/SseClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public void onOpen(EventSource eventSource, Response response) {
5050
@Override
5151
public void onEvent(EventSource eventSource, String id, String type, String data) {
5252
if ("[DONE]".equals(data)) {
53+
sseEmitters.sendToClientDone(userId);
5354
System.out.println("ML 응답 스트림 종료 신호 수신");
5455
return;
5556
}

0 commit comments

Comments
 (0)