@@ -103,7 +103,7 @@ public String shutdown(Response response) throws ApplicationException {
103
103
return jsonRpcHandler .createErrorResponse ("Not in ready state" , ErrorCodes .NOT_INITIALIZED );
104
104
}
105
105
106
- sseHandler .closeAllConnections ();
106
+ sseHandler .closeAll ();
107
107
sessionState = SessionState .DISCONNECTED ;
108
108
109
109
JsonRpcResponse jsonResponse = new JsonRpcResponse ();
@@ -131,13 +131,12 @@ public String events(Response response, Request request) throws ApplicationExcep
131
131
}
132
132
133
133
String clientId = UUID .randomUUID ().toString ();
134
- SSEHandler . SSESession session = sseHandler .createSession (clientId );
134
+ sseHandler .registerClient (clientId , response );
135
135
sseHandler .setupSSEHeaders (response );
136
-
137
- // Send initial connection event
138
- session .sendEvent (Events .CONNECTED , "{\" clientId\" :\" " + clientId + "\" }" );
139
- return session .getOutput ();
140
-
136
+ // 发送初始连接事件
137
+ sseHandler .sendEvent (clientId , Events .CONNECTED , "{\" clientId\" :\" " + clientId + "\" }" );
138
+ // SSE 连接应保持打开,返回空字符串即可
139
+ return "" ;
141
140
} catch (Exception e ) {
142
141
LOGGER .log (Level .SEVERE , "SSE connection failed" , e );
143
142
response .setStatus (ResponseStatus .INTERNAL_SERVER_ERROR );
@@ -239,7 +238,7 @@ protected void handleShutdown(JsonRpcRequest request, JsonRpcResponse response)
239
238
return ;
240
239
}
241
240
242
- sseHandler .closeAllConnections ();
241
+ sseHandler .closeAll ();
243
242
sessionState = SessionState .DISCONNECTED ;
244
243
245
244
response .setId (request .getId ());
0 commit comments