Serve websocket clients straight from your program.
Run a websocket server from your Nu tree. Every client that connects gets its own arm of the program, and you decide what travels over the wire.
See it.
The server keeps track of who is connected. One arm of your program runs for each client, and ends when they go.
The lifetime of an arm is the lifetime of a socket.
A connection opens and an arm of your tree starts. It closes and the arm ends. That holds in both directions, so there is no reaping pass and no orphan to find later.
Nothing about the messages is fixed for you. The browser UI is this fabric with a protocol stacked on top, and yours stacks the same way.
What you can do with it.
A real websocket server, written as part of the program.
any protocol
Speak whatever you want.
The fabric handles the sockets and hands each arm its connection. What you send over it is yours: JSON, msgpack, a binary format you invented.
per connection
One arm per client.
Each live connection runs its own arm of the tree, with its own state. Clients cannot see each other unless a fabric you bound lets them.
bracketed
Close is not your problem.
Sockets open and close inside the bracket, and the arm follows. No lifecycle callbacks, no cleanup you have to keep in sync with teardown.
Combines well with.
ws_server holds the connections. Other fabrics give each client something worth saying.
nustd.ui
Reactive web UI.
The browser UI is ws_server with a wire codec and an SPA on top. One live tab is one arm.
nustd.proxy
Fabrics on the wire.
Put a bound fabric on the network when you want remote calls rather than a protocol of your own.
nustd.kv
Durable state fabric.
Back the connections with state that outlives them, and push changes out as they land.
Try Nu.
One command gets you the wheel with every fabric. Then follow the movies tutorial to build a real app in an afternoon.
01 Install
pip install "nustack-py[all]"02 Run the demo
nu demo movies03 Build your app
Browse examplesLike what you see?
The project is young. Star it, join the room, watch what we ship next.