kb-server 0.0.1-beta.34 → 0.0.1-beta.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -63,19 +63,19 @@ const packSSE = (sseHandlers, options) => {
|
|
|
63
63
|
if (typeof execution !== "function") {
|
|
64
64
|
throw new create_errors_1.CommonErrors.ResourceNotFound.APINotFound();
|
|
65
65
|
}
|
|
66
|
-
// 写请求头
|
|
67
|
-
res.writeHead(200, {
|
|
68
|
-
"Content-Type": "text/event-stream",
|
|
69
|
-
"Cache-Control": "no-cache",
|
|
70
|
-
Connection: "keep-alive",
|
|
71
|
-
});
|
|
72
66
|
// 在调用 execution 前添加中断监听
|
|
73
67
|
let isClientConnected = true;
|
|
74
68
|
// 监听客户端断开事件
|
|
75
|
-
|
|
69
|
+
res.on("close", () => {
|
|
76
70
|
isClientConnected = false; // 标记连接已断开
|
|
77
71
|
logger_1.logger.log("info", `客户端已断开 - RequestId: ${requestId}`);
|
|
78
72
|
});
|
|
73
|
+
// 写请求头
|
|
74
|
+
res.writeHead(200, {
|
|
75
|
+
"Content-Type": "text/event-stream",
|
|
76
|
+
"Cache-Control": "no-cache",
|
|
77
|
+
Connection: "keep-alive",
|
|
78
|
+
});
|
|
79
79
|
const send = (event, message) => {
|
|
80
80
|
if (!isClientConnected) {
|
|
81
81
|
logger_1.logger.log("warning", "客户端已断开,停止发送");
|