MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / handleBridgeEvents

Function handleBridgeEvents

scripts/dev-web-bridge-node.ts:284–303  ·  view source on GitHub ↗
(
  channel: keyof DesktopEventMap,
  request: http.IncomingMessage,
  response: http.ServerResponse,
)

Source from the content-addressed store, hash-verified

282}
283
284function handleBridgeEvents(
285 channel: keyof DesktopEventMap,
286 request: http.IncomingMessage,
287 response: http.ServerResponse,
288) {
289 response.writeHead(200, {
290 'content-type': 'text/event-stream; charset=utf-8',
291 'cache-control': 'no-cache, no-transform',
292 connection: 'keep-alive',
293 })
294 response.write('retry: 1000\n\n')
295
296 const clients = channel === 'terminalEvent' ? terminalEventClients : desktopEventClients
297 clients.add(response)
298 sseClients.add(response)
299 request.on('close', () => {
300 clients.delete(response)
301 sseClients.delete(response)
302 })
303}
304
305const server = http.createServer((request, response) => {
306 const requestUrl = new URL(request.url ?? '/', `http://${host}`)

Callers 1

Calls 1

writeMethod · 0.65

Tested by

no test coverage detected