darto_ws 1.1.0
darto_ws: ^1.1.0 copied to clipboard
WebSocket plugin for Darto — route-integrated, same port, Hono-style. Rooms, broadcast and Redis pub/sub for multi-instance fanout.
1.1.0 #
- Rooms + broadcast (
WsHub) — connection registry that tracks sockets and rooms, with a fluent fanout API:hub.to(room).except(ws).send(text)/sendJson(map)/sendBytes(bytes)andhub.broadcast(). Usable anywhere aContextis available (WS callbacks, HTTP routes, jobs). DartoWebSocketergonomics —ws.id(UUID v4),ws.rooms,ws.join(room),ws.leave(room),ws.to(room)andws.broadcast(). The socket auto-leaves every room on close.hub.middleware()— registers the hub on the requestContextsoupgradeWebSocketfactories can pick it up automatically; read it from any handler viawsHub(c).RedisWsAdapter— pub/sub backend for multi-instance fanout. Each hub publishes to per-room Redis channels (anddarto_ws:allforbroadcast()); peers re-fanout to their local sockets while origin-id tagging suppresses self-echo. Attach viahub.attachAdapter(...).- Breaking:
WSHandler.onCloseandWSHandler.onErrornow receive the closingDartoWebSocket. Callers add an_orwsparameter (onClose: (ws) => …). Required so callbacks can readws.id/ws.roomsbefore the hub tears the socket down.
1.0.1 #
- Require
darto: ^1.1.0. - docs: add Support section to README.
1.0.0 #
- Initial stable release.