Networking · class

LoopbackNetwork

A set of endpoints that can reach each other, holding the clock they share.

Explained in Networking and rollback.

class LoopbackNetwork
import { LoopbackNetwork } from '@driftengine/network';

In depth

The network owns the clock rather than each endpoint owning one, because two endpoints whose clocks advanced separately would let a test deliver a message before it was sent.

Accessors

NameTypeDescription
nowgetnumber

Methods

open

open(options: LoopbackOptions): LoopbackTransport

Make an endpoint. Its impairment is its own, so a link can be bad in one direction only.

ParameterTypeDescription
optionsLoopbackOptions

advance

advance(ms: number): void

Move the shared clock, delivering everything whose time has come.

ParameterTypeDescription
msnumber
More

Delivery happens in send order among messages due at the same instant, which is what makes a schedule reproducible: two messages with identical arrival times would otherwise be delivered in whatever order a queue happened to hold them.

reach

reach(to: PeerId): LoopbackTransport[]

Every endpoint, for a caller draining them all.

ParameterTypeDescription
toPeerId