|
@@ -8,7 +8,6 @@ import com.sxtvs.open.core.auth.LoginRequired;
|
|
|
import com.sxtvs.open.core.sls.AliyunLogger;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Controller;
|
|
@@ -21,7 +20,6 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|
|
@Controller
|
|
|
@RequestMapping("/user")
|
|
|
@NoAPIResponse
|
|
|
-@Slf4j
|
|
|
public class SseController {
|
|
|
|
|
|
@Resource
|
|
@@ -33,16 +31,12 @@ public class SseController {
|
|
|
@Autowired
|
|
|
private ThreadPoolExecutor poolExecutor;
|
|
|
|
|
|
- @GetMapping(path = "/sse", produces = MediaType.TEXT_EVENT_STREAM_VALUE, headers = "Cache-Control=no-cache")
|
|
|
+ @GetMapping(path = "/sse", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
|
|
@NoAPIResponse
|
|
|
public SseEmitter handleSse(@RequestParam("token") String token) throws IOException {
|
|
|
SseEmitter sseEmitter = new SseEmitter(300 * 1000L); // 设置超时时间
|
|
|
sseService.monitor(token, sseEmitter);
|
|
|
- sseEmitter.send(SseEmitter.event().name("data").data("data"));
|
|
|
- sseEmitter.onCompletion(() -> {
|
|
|
- log.info("连接关闭");
|
|
|
- sseEmitter.complete();
|
|
|
- });
|
|
|
+ sseEmitter.send("data");
|
|
|
return sseEmitter;
|
|
|
}
|
|
|
|
|
@@ -55,8 +49,7 @@ public class SseController {
|
|
|
SseEmitter sseEmitter = new SseEmitter(0L); // 设置超时时间
|
|
|
sseService.monitor(kimiChat.getGroupId(), sseEmitter);
|
|
|
kimiChatService.create(kimiChat);
|
|
|
- sseEmitter.send(SseEmitter.event().name("hello").data("hello"));
|
|
|
- sseEmitter.complete();
|
|
|
+ sseEmitter.send("data");
|
|
|
return sseEmitter;
|
|
|
}
|
|
|
|