feat(chat): cut over to single SSE endpoint
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.superbiz.agent.controller.sse;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
final class SseEmitterChatSink implements ChatSseSink {
|
||||
|
||||
private final SseEmitter emitter;
|
||||
|
||||
SseEmitterChatSink(SseEmitter emitter) {
|
||||
this.emitter = Objects.requireNonNull(emitter, "emitter must not be null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(String name, Object payload) throws IOException {
|
||||
emitter.send(SseEmitter.event()
|
||||
.name(name)
|
||||
.data(payload, MediaType.APPLICATION_JSON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete() {
|
||||
emitter.complete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user