MqttPayload
このコンテンツはまだ日本語訳がありません。
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.
Type Parameters
Section titled “Type Parameters”T = unknown
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MqttPayload<
T>(bytes,codec,topic?):MqttPayload<T>
Defined in: src/io/broker/MqttMessages.ts:43
Parameters
Section titled “Parameters”Uint8Array
Raw payload bytes exactly as received from the broker.
MqttCodec<unknown>
topic?
Section titled “topic?”string
Topic the payload arrived on — carried into decode errors.
Returns
Section titled “Returns”MqttPayload<T>
Properties
Section titled “Properties”
readonlybytes:Uint8Array
Defined in: src/io/broker/MqttMessages.ts:45
Raw payload bytes exactly as received from the broker.
Accessors
Section titled “Accessors”byteLength
Section titled “byteLength”Get Signature
Section titled “Get Signature”get byteLength():
number
Defined in: src/io/broker/MqttMessages.ts:52
Byte length of the raw payload.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”entity()
Section titled “entity()”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.
Type Parameters
Section titled “Type Parameters”U = T
Returns
Section titled “Returns”U
text()
Section titled “text()”text():
string
Defined in: src/io/broker/MqttMessages.ts:57
UTF-8 view of the raw bytes. Cached after the first call.
Returns
Section titled “Returns”string
toString()
Section titled “toString()”toString():
string
Defined in: src/io/broker/MqttMessages.ts:94
Alias of text — keeps ${msg.payload} readable in logs.
Returns
Section titled “Returns”string
