Networking · class

ScriptSession

Explained in Networking and rollback.

class ScriptSession implements Replicator
import { ScriptSession } from '@driftengine/network';

Constructor

new

constructor(options: ScriptSessionOptions)
ParameterTypeDescription
optionsScriptSessionOptions

Properties

NameTypeDescription
selfreadonlynumber
authorityreadonlyboolean

Accessors

NameTypeDescription
participantsgetnumber
confirmedgetnumberThe highest tick every participant's input has arrived for, or -1 when nothing tracks it.
haltedgetboolean
haltReasongetstring
slotsgetnumber

Methods

follow

follow(driver: SessionStatus): this

Point this at the driver whose status a script reads.

ParameterTypeDescription
driverSessionStatus

replicate

replicate(slot: number, value: number): void

Publish a value in one of this peer's slots. Out of range does nothing.

ParameterTypeDescription
slotnumber
valuenumber

replicated

replicated(participant: number, slot: number): number

Read a participant's slot. Out of range answers zero, which is total and allocates nothing.

ParameterTypeDescription
participantnumber
slotnumber

encode

encode(into: Uint8Array, _tick?: number): number

Every slot, as bytes. See the header: this is its own Replicator.

ParameterTypeDescription
intoUint8Array
_tick?number
More

The tick is taken and ignored, and the parameter is written out rather than dropped: a shorter signature still satisfies the interface, and then a reader has to open authority.ts to learn that the second argument exists at all.

apply

apply(from: Uint8Array, _tick?: number): void
ParameterTypeDescription
fromUint8Array
_tick?number