Realtime Chat — built with StreetJS

WebSockets · Presence · Channels — authenticated, bounded, benchmarked.

Architecture

1
2
3
4
Client ──WS upgrade + JWT auth──▶ StreetWebSocketServer
                                     └─ ChannelHub: rooms · presence · typing · history
                                          (bounded connections, heartbeat, 512 KB frame cap)
                                          └─ (scale-out) optional Redis pub/sub in front of ChannelHub

Auth runs at the upgrade — unauthenticated sockets are rejected before the connection is established (verified by the smoke test). ChannelHub provides rooms, reference-counted presence, typing indicators, and a bounded per-room history buffer.

Run it locally

1
2
3
npm run build -w packages/core
node examples/reference-apps/realtime-chat/server.mjs        # :3000
node examples/reference-apps/realtime-chat/smoke-test.mjs    # 8/8 checks

Client frames: join, leave, message, typing. Server emits presence:snapshot, history, presence:join/leave, typing, message.

Performance (MEASURED — relative, in-memory single instance)

10 subscribers × 2000 messages → 20,000/20,000 delivered in ~0.18s (~115K deliveries/s). Horizontal scale needs a Redis pub/sub fan-out in front of ChannelHub.publish and a Postgres-backed history store.

Learning path

  1. WebSocket basics
  2. Channels & presence
  3. Realtime chat
  4. Multiplayer — low-latency state sync

A real, CI-tested reference app. Browse all demos in the Showcase.