WebSocket
DocsWebSockets give you a persistent, bidirectional connection between client and server. Unlike SSE, both sides can send messages at any time. The websocket() middleware handles the protocol upgrade and lifecycle for you. Define onOpen, onMessage, and onClose callbacks, and call agents or other async code from inside them. For one-way streaming, see SSE Stream. For peer-to-peer browser communication, see WebRTC.
Disconnected
Heartbeat ping every 15s; reconnects after drops, not page refresh
Connect to open the socket and start sending messages
Reference Code
Loading...
Ready
Output will appear here...