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

Function sendSseEvent

scripts/dev-web-bridge-node.ts:44–54  ·  view source on GitHub ↗
(
  clients: Set<http.ServerResponse>,
  channel: TChannel,
  event: DesktopEventMap[TChannel],
)

Source from the content-addressed store, hash-verified

42}
43
44function sendSseEvent<TChannel extends keyof DesktopEventMap>(
45 clients: Set<http.ServerResponse>,
46 channel: TChannel,
47 event: DesktopEventMap[TChannel],
48) {
49 const payload = JSON.stringify({ channel, event })
50 for (const client of clients) {
51 client.write(`event: ${channel}\n`)
52 client.write(`data: ${payload}\n\n`)
53 }
54}
55
56async function writeUniqueTextFile(directoryPath: string, fileName: string, content: string) {
57 const parsed = path.parse(fileName)

Callers 1

Calls 1

writeMethod · 0.65

Tested by

no test coverage detected