We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I like the design of the new Deno.serveHttp API. I think a similar design would work well for WebSockets, too.
Deno.serveHttp
Example API:
async function acceptWebSocket( conn: Deno.Conn, httpConn: Deno.RequestEvent ): Promise<WebSocket> {}
Example usage:
for await (const conn of Deno.listen({ port: 80 })) { handleConn(conn); } async function handleConn(conn: Deno.Conn) { for await (const httpConn of Deno.serveHttp(conn)) { handleHttpConn(conn, httpConn); } } async function handleHttpConn(conn: Deno.Conn, httpConn: Deno.RequestEvent) { try { const ws = await Deno.acceptWebSocket(conn, httpConn); ws.onopen = todo; ws.onmessage = todo; ws.onerror = todo; ws.onclose = todo; } catch { httpConn.respondWith(new Response("Failed to accept WebSocket", { status: 400 })); } } function todo() {}
The text was updated successfully, but these errors were encountered:
Duplicate of #10211
Sorry, something went wrong.
Closing as duplicate of #10211
No branches or pull requests
I like the design of the new
Deno.serveHttp
API. I think a similar design would work well for WebSockets, too.Example API:
Example usage:
The text was updated successfully, but these errors were encountered: