Examples
Runnable examples live in examples/. Clone the repo and run pnpm install first.
chat — roles in one room
A human (user) and an AI participant (agent) join the same room with different surfaces. Shows a shared join + message event, role-specific verbs (say vs announce), and conn.role.
pnpm --filter @super-line/example-chat startDemonstrates: roles, shared requests, events & rooms.
react-chat — browser app
A live React chat (Vite + a WS server). Open two browser tabs to chat in real time; shows the React hooks, a presence topic, and a room broadcast.
pnpm --filter @super-line/example-react-chat dev # http://localhost:5173auth — roles as an authorization boundary
Token auth with an admin and a user role. whoami is shared; secret is admin-only. A user calling secret gets NOT_FOUND; a bad token is rejected at the upgrade.
pnpm --filter @super-line/example-auth startDemonstrates: auth, NOT_FOUND enforcement, errors.
presence — introspection, targeted send & server→client requests
Boots two nodes sharing one in-memory bus (no Docker needed) and shows the server-side toolkit across nodes: cluster.count/topology/isOnline, a toUser(...).emit from the node that doesn't hold the socket, and a toConn(id).request(...) where one node asks a client a question and awaits the typed reply (the client answers via client.implement).
pnpm --filter @super-line/example-presence startDemonstrates: introspection & presence.
scaling — multi-node fan-out
Boots two nodes against one Redis and proves a topic publish, a room broadcast, and a serverToServer event from node B all reach a client on node A. Needs Docker/Redis.
docker run --rm -p 6379:6379 redis:7
pnpm --filter @super-line/example-scaling startDemonstrates: scaling & adapters, serverToServer.