websocketx
Websocket for httpx.
Summary
| Latest Version | Unknown |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:24 |
Tags
Installation
nimble install websocketx
choosenim install websocketx
git clone https://github.com/ringabout/websocketx
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| websocketx | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://github.com/ringabout/websocketx |
|---|---|
| Homepage | https://github.com/ringabout/websocketx |
| Registry Source | nimble_official |
README
websocketx
Nim websocket for httpx.
Based on https://github.com/treeform/ws
Installation
nimble install websocketx
Usage
httpx
import options, asyncdispatch, httpx, websocketx
proc onRequest(req: Request) {.async.} =
if req.path.isSome:
if req.path.get == "/ws":
var ws = await newWebSocket(req)
await ws.send("Welcome to simple echo server")
while ws.readyState == Open:
let packet = await ws.receiveStrPacket()
await ws.send(packet)
else:
req.send(Http404)
else:
req.send(Http404)
run(onRequest)
asyncdispatch
import websocketx, asyncdispatch, asynchttpserver
var server = newAsyncHttpServer()
proc cb(req: Request) {.async.} =
if req.url.path == "/ws":
var ws = await newWebSocket(req)
await ws.send("Welcome to simple echo server")
while ws.readyState == Open:
let packet = await ws.receiveStrPacket()
await ws.send(packet)
else:
await req.respond(Http404, "Not found")
waitFor server.serve(Port(9001), cb)