flame_multiplayer library

Two players on two machines, for a game that steps in fixed steps.

Four ways two machines share a game, over any PeerWire:

  • PeerRoom — who is who, a handshake that says what each machine plays, and conversations on one wire that do not hear each other.
  • RollbackPlay — both play one simulation in step, each driving their own player, with an ending both machines agree on.
  • BatonStream — turns: the machine whose turn it is plays, the other replays what it is told, and the turn goes across with the state.
  • PeerFeed — each plays a game of its own and tells the other where it is: a ghost, a rival's score.

Under them, RollbackSession is rollback itself, and LoopbackWire two ends of a wire in one process, late and lossy as a test asks. The wire to a real network is an adapter: flutter3d_net's NetTransportWire for its relay and WebRTC transports, flame_multiplayer_dashwire for a dashwire connection. Nothing here depends on either.

A game calls them from its own fixed step — Flame's HasFixedStep in the bridged games — so what happens first within a step stays the game's to say.

Classes

BatonStream
Turns across two machines: the one holding the baton runs the game, and the other replays what it is told.
LoopbackWire
Two PeerWires joined to each other in one process, as late and as lossy as a test asks, and repeatable from its seed.
PeerFeed
Two machines playing their own games side by side — a race over the same course — each telling the other where it is.
PeerRoom
The room two machines meet in, over the one PeerWire a relay gives them.
PeerWire
Whatever carries messages between the two machines: a relay's WebSocket, a WebRTC data channel, a game networking library's connection.
RollbackPlay<S>
One simulation run on two machines in step, each driving its own player, through a RollbackSession.
RollbackSession<S>
A fixed-step game kept in step on two machines over a PeerWire, each sending its own player's hands.