deno.land / x / alosaur@v1.1.1 / examples / sse / chat.handler.ts

chat.handler.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const clients = new Map<number, Function>();let clientId = 0;function dispatch(msg: string): void { for (const client of clients.values()) { client(msg); }}
export async function ChatHandler(send: Function): Promise<void> { const id = ++clientId; clients.set(id, send); dispatch(`Connected: [${id}]`);}
alosaur

Version Info

Tagged at
a year ago