feat: sse

This commit is contained in:
2026-06-24 12:42:34 +08:00
parent ab2a2dbf7f
commit aa9a0732d6

View File

@@ -99,7 +99,11 @@ public class SseConnectionManager {
}
/**
* 移除连接
* 移除连接(仅清理内部 Map不操作 SseEmitter
*
* SseEmitter 生命周期由 Spring 管理onCompletion/onTimeout/onError 回调),
* 此方法仅负责从内部映射表中移除引用。不调用 emitter.complete()
* 避免向已断开的客户端写入数据导致 IOException 扩散到 GlobalExceptionHandler。
*
* @param userId 用户账号 ID
* @param connectionId 连接 ID
@@ -116,11 +120,6 @@ public class SseConnectionManager {
}
if (removed != null) {
try {
removed.complete();
} catch (Throwable ignored) {
// 客户端断开后响应可能已不可用
}
log.info("[SSE] 连接已移除, userId={}, connectionId={}, onlineConnections={}",
userId, connectionId, getOnlineCount());
}