Create a new MqttWire instance for a client connection.
Lifecycle hooks (onSend and onConnect are required)
Configuration options
Get client ID (from CONNECT or assigned by server).
Get current connection state.
Check if connected.
Get client's maximum packet size (from CONNECT).
Get client's receive maximum (from CONNECT).
Get protocol version (negotiated from client CONNECT).
Disconnect the client.
Sends DISCONNECT packet (MQTT 5.0), waiting at most closeTimeoutMs for
onSend, and cleans up state. While an error is
already closing the session, it returns at once and leaves the close to
finish, so onDisconnect may run after it resolves.
Disconnect reason (default: 0x00 normal)
Optionalproperties: DisconnectPropertiesDISCONNECT properties
Publish a message to the client.
Topic name
Message payload
Publish options
Packet ID for QoS > 0, undefined for QoS 0
Process incoming data from transport.
Call this method with chunks of data received from the transport (TCP socket, WebSocket, etc.). Complete packets will be parsed and appropriate hooks called.
Resolves even when a hook throws: the error goes to onError, the
session ends (DISCONNECT 0x80 on 5.0) and onDisconnect runs with it.
Frames after the failing one in the same chunk are dropped.
Incoming data chunk
Force cleanup of all state, ready for a new connection. Ends a live
session first, so onDisconnect runs once for it; a session that has
already ended doesn't fire it again.
MQTT protocol connection state machine (server-side).
Handles incoming MQTT client connections, protocol parsing, encoding, QoS flows, keepalive, and connection lifecycle. Transport-agnostic: bytes in via
receive(), bytes out viaonSendhook.Example