Networking · function

decode

Read a message's header into out. false when the bytes are not a message this version knows.

Explained in Networking and rollback.

function decode(message: Uint8Array, out: DecodedMessage): boolean
import { decode } from '@driftengine/network';

Parameters

ParameterTypeDescription
messageUint8Array
outDecodedMessage

In depth

A payload is located rather than copied. payloadAt and payloadBytes point into the buffer the caller was handed, which the transport may reuse the moment the sink returns — the same borrow MessageSink documents. A caller keeping a payload copies it, and one feeding it straight to RewindLoop.supply does not need to.