|
@@ -8,6 +8,7 @@ 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;
|
|
@@ -20,6 +21,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|
|
@Controller
|
|
|
@RequestMapping("/user")
|
|
|
@NoAPIResponse
|
|
|
+@Slf4j
|
|
|
public class SseController {
|
|
|
|
|
|
@Resource
|
|
@@ -37,7 +39,10 @@ public class SseController {
|
|
|
SseEmitter sseEmitter = new SseEmitter(300 * 1000L); // 设置超时时间
|
|
|
sseService.monitor(token, sseEmitter);
|
|
|
sseEmitter.send(SseEmitter.event().name("data").data("data"));
|
|
|
- sseEmitter.complete();
|
|
|
+ sseEmitter.onCompletion(() -> {
|
|
|
+ log.info("连接关闭");
|
|
|
+ sseEmitter.complete();
|
|
|
+ });
|
|
|
return sseEmitter;
|
|
|
}
|
|
|
|