Created
November 12, 2019 22:33
-
-
Save treeform/1f28dafa53925ba6c56d698a999c5f7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ws, asyncdispatch, asynchttpserver | |
proc cb(req: Request) {.async.} = | |
var ws = await newWebSocket(req) | |
echo "Got ws connecting with protocol ", ws.protocol | |
if ws.protocol == "alpha": | |
await ws.send("Welcome Protocol Alpha") | |
ws.close() | |
var server = newAsyncHttpServer() | |
waitFor server.serve(Port(9001), cb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment