Skip to main content

Crate thread_relay

Crate thread_relay 

Source
Expand description

The relay Hub — the socket-free core of a Thread presence relay.

A relay is deliberately simple and stateless-in-spirit: it holds only ephemeral occupant positions, so a restart just means clients reconnect. All the wire behaviour (presence-wire-v0.1) lives here as a pure state machine — handle(inbound) -> [outbound] — so it’s unit-testable with no network, and can be certified against the very same wire checker (thread_conformance::relay) that any browser author would run.

Decentralization by design: this is a reference relay anyone can cargo run (or docker run) on a cheap host. A world names its own relay(s) in its manifest; Pixygon runs at most one relay among many. The standard is the wire, not any single server — so presence survives any one operator disappearing.

Structs§

Hub
The relay hub: worlds, occupants, and the wire state machine.
Outbound
A message the hub wants sent to a specific connection.

Enums§

Body
A wire payload: JSON text (join/pose/leave) or a binary voice frame.
Inbound
An event coming into the hub.

Constants§

MAX_VOICE_FRAME
Voice frames above this size are dropped (abuse guard) — 20 ms of 48 kHz stereo PCM16 is ~7.7 KB; conformant 16 kHz mono frames are ~640 bytes.

Functions§

serve_listener
Serve the relay on an already-bound listener until the process ends. This is the whole transport layer — the binary is just env parsing plus this call — exposed so tests (and embedders) can run an in-process relay on an ephemeral port, exactly like thread_rendezvous::serve_listener.

Type Aliases§

ConnId
A connection handle assigned by the transport layer (one per WebSocket).