Skip to main content

Crate banished_net

Crate banished_net 

Source
Expand description

Un-Banished multiplayer networking: the protocol between a game and the relay, and a WebSocket connection to the relay that works natively and in the browser.

The relay (apps/relay) keeps rooms. A host opens one and gets its code; players join with the code. The relay numbers the players in the order they come (the host is 0) and passes their data on, to one player or to all the others. It never reads the data: the game’s own messages (its lockstep turns, digests and saves) travel inside ToRelay::Send and FromRelay::Data. Every WebSocket message is one value, encoded with postcard.

Not in the original game, which has no multiplayer; see docs/MULTIPLAYER-PLAN.md, step 5.

Structs§

Connection
A connection to a relay (ws://host:port).

Enums§

FromRelay
The relay to a game.
State
The state of a connection.
ToRelay
A game to the relay.

Functions§

decode
Decodes a WebSocket binary message.
encode
Encodes a protocol value (or a game message) for a WebSocket binary message.