feat: add closeSSEStream callback to RequestHandlerExtra (#1166)
This commit is contained in:
parent
6c863c8e75
commit
fab7e1e9b3
1 changed files with 147 additions and 11 deletions
|
|
@ -649,7 +649,15 @@ export class StreamableHTTPServerTransport implements Transport {
|
|||
|
||||
// handle each message
|
||||
for (const message of messages) {
|
||||
this.onmessage?.(message, { authInfo, requestInfo });
|
||||
// Build closeSSEStream callback for requests when eventStore is configured
|
||||
let closeSSEStream: (() => void) | undefined;
|
||||
if (isJSONRPCRequest(message) && this._eventStore) {
|
||||
closeSSEStream = () => {
|
||||
this.closeSSEStream(message.id);
|
||||
};
|
||||
}
|
||||
|
||||
this.onmessage?.(message, { authInfo, requestInfo, closeSSEStream });
|
||||
}
|
||||
// The server SHOULD NOT close the SSE stream before sending all JSON-RPC responses
|
||||
// This will be handled by the send() method when responses are ready
|
||||
|
|
|
|||
Loading…
Reference in a new issue