Networking · class

LoopbackTransport

Explained in Networking and rollback.

class LoopbackTransport implements Transport
import { LoopbackTransport } from '@driftengine/network';

Constructor

new

constructor(network: LoopbackNetwork, options: LoopbackOptions)
ParameterTypeDescription
networkLoopbackNetwork
optionsLoopbackOptions

Properties

NameTypeDescription
selfreadonlyPeerId

Accessors

NameTypeDescription
stategetTransportState
sentgetnumber
droppedgetnumber

Methods

send

send(to: PeerId, message: Uint8Array): void

Queue a message for everyone it is addressed to, impaired.

ParameterTypeDescription
toPeerId
messageUint8Array
More

The bytes are copied here and nowhere else. A caller sending from a reusable buffer — which every caller in this package does — would otherwise have the buffer overwritten before delivery, and the message that arrived would be whatever was sent most recently. That bug looks exactly like a reordering bug and is not one.

drain

drain(into: MessageSink): void
ParameterTypeDescription
intoMessageSink

close

close(): void

accept

accept(pending: Pending): void

Called by the network. Not for a consumer.

ParameterTypeDescription
pendingPending

deliverDue

deliverDue(nowMs: number): void

Called by the network when the clock moves. Not for a consumer.

ParameterTypeDescription
nowMsnumber