Networking · class

WebSocketTransport

Explained in Networking and rollback.

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

Constructor

new

constructor(options: WebSocketTransportOptions)
ParameterTypeDescription
optionsWebSocketTransportOptions

Properties

NameTypeDescription
selfreadonlyPeerId

Accessors

NameTypeDescription
stategetTransportState
droppedgetnumberMessages dropped: because nothing drained, which a consumer watching for a stalled tab reads, or because nothing could be read out of them.

Methods

send

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

Send, or do nothing if the socket is not open yet.

ParameterTypeDescription
_toPeerId
messageUint8Array
More

Nothing is queued while connecting, deliberately. Every message this package sends is addressed to a tick, and a tick that has passed by the time the socket opens is a tick nobody can use. Flushing a backlog of stale inputs on connect is worse than having sent none.

drain

drain(into: MessageSink): void
ParameterTypeDescription
intoMessageSink

close

close(): void