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