Networking · class
LoopbackNetwork
A set of endpoints that can reach each other, holding the clock they share.
Explained in Networking and rollback.
class LoopbackNetworkimport { 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
| Name | Type | Description |
|---|---|---|
nowget | number |
Methods
open
open(options: LoopbackOptions): LoopbackTransportMake an endpoint. Its impairment is its own, so a link can be bad in one direction only.
| Parameter | Type | Description |
|---|---|---|
options | LoopbackOptions |
advance
advance(ms: number): voidMove the shared clock, delivering everything whose time has come.
| Parameter | Type | Description |
|---|---|---|
ms | number |
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.
| Parameter | Type | Description |
|---|---|---|
to | PeerId |