( channel: keyof DesktopEventMap, request: http.IncomingMessage, response: http.ServerResponse, )
| 282 | } |
| 283 | |
| 284 | function 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 | |
| 305 | const server = http.createServer((request, response) => { |
| 306 | const requestUrl = new URL(request.url ?? '/', `http://${host}`) |
no test coverage detected