|
@@ -36,7 +36,7 @@ public class SseController {
|
|
|
@Resource
|
|
|
private KimiChatServiceImpl kimiChatService;
|
|
|
|
|
|
- @PostMapping(path = "/chat"/*, produces = MediaType.TEXT_EVENT_STREAM_VALUE*/)
|
|
|
+ @PostMapping(path = "/chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
|
|
@NoAPIResponse
|
|
|
public SseEmitter handleSsePost(@RequestBody KimiChat kimiChat) throws IOException {
|
|
|
SseEmitter sseEmitter = new SseEmitter(0L); // 设置超时时间
|
|
@@ -46,4 +46,23 @@ public class SseController {
|
|
|
|
|
|
return sseEmitter;
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping(path = "/test", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
|
|
+ @NoAPIResponse
|
|
|
+ public SseEmitter test(@RequestBody KimiChat kimiChat) throws IOException {
|
|
|
+ SseEmitter sseEmitter = new SseEmitter(0L); // 设置超时时间
|
|
|
+ sseService.monitor(kimiChat.getGroupId(), sseEmitter);
|
|
|
+
|
|
|
+ sseEmitter.send(SseEmitter.event().name("data").data("hello"));
|
|
|
+ new Thread(() -> {
|
|
|
+ try {
|
|
|
+ sseEmitter.send(SseEmitter.event().name("data").data("你好"));
|
|
|
+ sseEmitter.send(SseEmitter.event().name("message").data("你好ya"));
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ return sseEmitter;
|
|
|
+ }
|
|
|
}
|