Server Reference
This page documents the server-facing HTTP/WebSocket endpoints and the protobuf messages used for signaling.
HTTP endpoints (management)
Section titled “HTTP endpoints (management)”POST /v1/hubs/create?id={hubId}- create a fixed hub. Accepts optionalhubMetadataandpeerMetadataquery params (JSON-encoded).GET /v1/hubs/join?id={hubId}- join a fixed hubPOST /v1/random-hubs/create- create a random hubGET /v1/random-hubs/join?id={hubId}- join a random hubGET /v1/ip-hubs/join-or-create- join or create an IP hub (server derives hubId from request IP)
Note: The docs repository contains
proto/definitions describing the WebSocket messages used by the server and client for signaling.
WebSocket protocol
Section titled “WebSocket protocol”The server speaks a binary protobuf-based protocol for efficiency. The primary messages are:
ClientMessage- messages sent from client to server (create/join, sendOffer, sendAnswer, etc.)ServerMessage- messages sent from server to client with hub info, offers, answers, peer join/leave notifications.
Typical flow
Section titled “Typical flow”- Client connects to the WS endpoint with the hub join/create path and query params
- Server responds with
ServerMessage.hubInfoMessagecontaining peer list and assignedmyPeerId - Clients exchange offers and answers via
ClientMessage.sendOfferMessage/ClientMessage.sendAnswerMessagewhich the server forwards to the target peer
Protobuf notes and best practices
Section titled “Protobuf notes and best practices”- Messages use string-encoded JSON for
metadatafields; keepmetadatasmall to avoid large messages. - Consider adding validation for maximum string lengths in server-side logic.
- For very high-performance scenarios, evaluate FlatBuffers but for developer ergonomics protobuf is a good default.
Example: offer exchange
Section titled “Example: offer exchange”The client will send a sendOfferMessage containing answerPeerId and offerSdp.
The server will forward this to the target peer as a ServerMessage.offerMessage.
Further reading
Section titled “Further reading”- See
proto/client_message.protoandproto/server_message.protoin the repository - SDK: SDK Reference
- Guides: Hub types