Expand description
Bounded, versioned network protocol shared by native and browser game clients.
The protocol never accepts client positions or client-selected time steps. Native UDP is intentionally a thin primitive: accounts/encryption and NAT traversal remain outside this prototype. The first-party WebSocket gateway carries browser datagrams to the same authority.
Modules§
- baselines
- Bounded, separate sent and installed snapshot histories.
- clock
- Correlated clock probes and a bounded interpolation delay. All times are supplied explicitly, making jitter/loss/reorder behavior testable offline.
- delta
- Versioned byte snapshot differences. Callers acknowledge exact baselines before using a delta.
- history
- Bounded authority history and clock estimates; rendering and transport are independent.
- local_
link - Bounded, independently instantiated supplied-time datagram router.
- reliable
- Bounded ordered event delivery over an unreliable transport. This is not encryption.
- time
- Transport clock shared by native sockets and browser hosts. Browser hosts explicitly supply monotonic microseconds; no unsupported Wasm OS clock call.
- udp
- Native sockets are optional by target; packet codecs remain available on wasm.
- websocket
- Bounded binary WebSocket transport for native/browser development sessions. First-party RFC 6455 handshake/framing; no extensions, text messages or TLS. The handshake SHA-1 is required by the protocol, never used for authentication. References: https://www.rfc-editor.org/rfc/rfc6455 and https://www.rfc-editor.org/rfc/rfc3174.
Structs§
- Input
Frame - Input
Queue - Deduplicates input redundancy and bounds per-client simulation backlog.
- Input
Queue Metrics - Queue-local activity since creation or the last
InputQueue::reset_metrics. - Player
Snapshot - Snapshot
- Timed
Input
Enums§
- Borrowed
Event - Borrowed v5 reliable/tactical envelope for an
reliable::EventSender::send_duecallback. Uses the owned packet codec, without cloning an EventPacket or its payload. Both wire families add 24 bytes to the payload; reliable events accept empty payloads, commands require 1..=900 bytes. No sequence policy or application payload validation is added; validate the outer session and game payload before receiver admission. Safe Rust requires disjoint output/input. - Client
Extension - Client
Packet - Encode
Error - Rejection from packet encoding. Field paths are stable diagnostic names; indices identify a zero-based input/player/epoch, never a byte offset.
- Input
Admission Error - Reason a checked input admission was rejected.
- Protocol
Error - Server
Extension - Server
Packet
Constants§
- BUTTON_
FIRE - BUTTON_
JUMP - BUTTON_
RELOAD - MAX_
INPUTS_ PER_ PACKET - MAX_
PACKET_ BYTES - MAX_
PITCH - MAX_
PLAYERS - MAX_
QUEUED_ INPUTS - PROTOCOL_
VERSION - Version 4 adds timed inputs, clock exchanges, snapshot ACK/deltas and commands.
Functions§
- decode_
client - decode_
server - encode_
client - Allocating compatibility wrapper using the same validated v5 writer as
encode_client_into. Accepted inputs, bytes and ProtocolError mapping are unchanged; returned Vec capacity is unspecified. - encode_
client_ into - Encode v5 into a disjoint caller slice without allocating. Success initializes exactly the returned prefix and leaves the tail untouched. Every error leaves the entire destination unchanged. Capacity means slice length, not any underlying Vec capacity; there is no internal scratch packet or retained state.
- encode_
server - Allocating compatibility wrapper for
encode_server_into. - encode_
server_ into - Server counterpart of
encode_client_into, with identical atomicity, tail, allocation and capacity guarantees. Preserves exact v5 float bits. - encoded_
client_ len - Exact v5 wire length after validating every client field; allocates nothing.
Includes the six-byte header and session/envelope overhead. See
encode_client_intofor the shared validation/precedence contract. - encoded_
server_ len - Exact validated v5 server wire length, without allocation. Inner delta bytes remain opaque: only outer tick ordering and byte length are checked, matching the legacy encoder/decoder. Does not authenticate/install/ACK a snapshot.
- sequence_
newer - RFC-1982-style comparison. Exactly half a sequence space is ambiguous and rejected.