Systems

Networking

87 symbols, imported from @driftengine/network.

Explained in Networking and rollback.

Classes

AuthorityHost
The machine whose world is the truth.
Fingerprint
An FNV-1a pair, fed bytes and numbers, answering sixteen hex characters.
InputLog
LockstepSession
LoopbackNetwork
A set of endpoints that can reach each other, holding the clock they share.
LoopbackTransport
PredictingClient
A machine that predicts its own player and corrects toward the authority.
RewindLoop
ScriptSession
StateInterpolator
Two authoritative states and where between them to draw.
WebRtcTransport
WebSocketTransport

Interfaces

AuthorityOptions
ClientOptions
DataChannelLike
What an RTCDataChannel satisfies. Declared rather than imported; see websocket.ts.
DecodedMessage
What a decoded message turned out to be. kind 0 means it did not decode.
Desync
FixtureMath
The trigonometry, supplied rather than imported.
FixtureResult
Impairment
InputLogOptions
LockstepOptions
LoopbackOptions
PeerConnectionLike
The part of RTCPeerConnection unreliableChannel needs.
Replicator
What a consumer packs and unpacks.
RewindOptions
SavablePosition
A seeded generator's position.
ScriptSessionOptions
SessionStatus
What a driver tells the façade about itself. Both session classes satisfy the parts they have.
Snapshotter
Somewhere state can be put and taken back.
SocketLike
What a browser WebSocket and a Node ws both satisfy. Named here so neither is imported.
Transport
WebRtcTransportOptions
WebSocketTransportOptions

Functions

combineSnapshotters
Several snapshotters as one, saving and restoring in the order given.
createDecoded
createFixture
The pair of arms, sharing one sine table and one starting state.
decode
Read a message's header into out. false when the bytes are not a message this version knows.
encodeAck
encodeFingerprint
encodeInput
Write an input frame into into, answering how many bytes it used, or -1 when it does not fit.
encodeJoin
encodeState
encodeWelcome
fingerprintSnapshot
A world snapshot's fingerprint.
randomSnapshotter
A generator, as one number.
simAbs
simAdd
simCompare
-1, 0 or 1. Present so a caller compares through this file rather than by hand.
simDiv
Divide. Deterministic rather than exact; see §3 of the header. Division by zero saturates.
simFrom
From an ordinary number. Truncates toward negative infinity, as everything here does.
simFromInt
From an integer, exactly, with no rounding to think about.
simMax
simMin
simMul
Multiply. Exact wherever the result is representable; see §2 of the header.
simNeg
simSqrt
Square root, by Newton's method on integers.
simSub
simTo
Back to an ordinary number. Exact: a division by a power of two.
unreliableChannel
A channel configured the way a simulation wants one.
worldSnapshotter
A world, through the identity-preserving snapshot @driftengine/entities owns.

Types

InputPredictor
How a missing input is guessed. previous is that participant's last confirmed input.
LockstepStatus
MessageSink
Where a drained message goes.
PeerId
Which participant a message is for or from. Small integers, assigned by the host.
SessionRole
What a role means is in this file's header, not in these names.
Sim
A fixed-point value: an integer, scaled by SIM_ONE, carried in a double.
SimStep
One fixed step. The signature LoopHooks.simulate has, so a consumer passes theirs straight in.
TransportState

Constants

BROADCAST
Send to everyone the transport can reach.
FINGERPRINT_BYTES
A fingerprint message is fixed: kind, participant, tick, and eight bytes of digest.
FIXTURE_BODIES
INPUT_HEADER_BYTES
Header bytes before an input run's payloads: kind, participant, first tick, count, stride.
MESSAGE_ACK
MESSAGE_FINGERPRINT
MESSAGE_INPUT
MESSAGE_JOIN
MESSAGE_PING
MESSAGE_STATE
MESSAGE_WELCOME
PROTOCOL_VERSION
The framing, which is small on purpose.
repeatLastInput
Repeat the last input seen from that participant. See the header for when this is wrong.
SIM_FRACTION_BITS
Fractional bits. The whole format is this number.
SIM_MAX
The largest and smallest representable raws, which is a double's exact integer range.
SIM_MIN
SIM_ONE
One, as a raw value.
STATE_HEADER_BYTES
Header bytes before a state payload: kind, tick, length.