121
return;
122
}
124
>
const payload = JSON.stringify(message);
125
>
const eventId = String(++this._lastEventId);
126
>
this._logService.debug(`[McpGateway][session ${this.id}] Broadcasting SSE event id=${eventId} to ${this._sseClients.size}`);
127
>
const lines = payload.split(/\r?\n/g);
128
>
const data = [
129
>
`id: ${eventId}`,
130
>
'event: message',
131
>
...lines.map(line => `data: ${line}`),
132
>
'',
133
>
''
134
>
].join('\n');
135
>
136
>
for (const client of [...this._sseClients]) {
137
>
if (client.destroyed || client.writableEnded) {
138
this._sseClients.delete(client);
139
continue;
140
}
142
>
client.write(data);
143
>
}
144
}
145