Aller au contenu
Français

MqttPayload

Ce contenu n’est pas encore disponible dans votre langue.

Defined in: src/io/broker/MqttMessages.ts:38

Lazily-decoding view over an inbound MQTT payload. The raw bytes are always available; text and entity decode on first call and cache the result — payloads are immutable and fan-out delivers the same instance to multiple handlers, so the common case is repeated reads of one value.

Decode errors are not cached: decoding is deterministic, so a repeated call re-throws an equivalent MqttDecodeError rather than returning a stale success.

T is the actor’s default inbound entity type; entity<U>() lets a single actor read a differently-typed payload on a specific topic.

T = unknown

new MqttPayload<T>(bytes, codec, topic?): MqttPayload<T>

Defined in: src/io/broker/MqttMessages.ts:43

Uint8Array

Raw payload bytes exactly as received from the broker.

MqttCodec<unknown>

string

Topic the payload arrived on — carried into decode errors.

MqttPayload<T>

readonly bytes: Uint8Array

Defined in: src/io/broker/MqttMessages.ts:45

Raw payload bytes exactly as received from the broker.

get byteLength(): number

Defined in: src/io/broker/MqttMessages.ts:52

Byte length of the raw payload.

number

entity<U>(): U

Defined in: src/io/broker/MqttMessages.ts:69

Decode the payload via the actor’s codec (default: JSON). Cached after the first successful call; U is a type-assertion convenience over the same cached value, not a re-decode with a different codec. Throws MqttDecodeError (carrying the topic + raw bytes) on a malformed payload — non-MqttDecodeError codec throws are wrapped.

U = T

U


text(): string

Defined in: src/io/broker/MqttMessages.ts:57

UTF-8 view of the raw bytes. Cached after the first call.

string


toString(): string

Defined in: src/io/broker/MqttMessages.ts:94

Alias of text — keeps ${msg.payload} readable in logs.

string