The Client class provides an MQTT Client that can be used to connect to a MQTT broker and publish/subscribe messages.
The Client class is not meant to be used directly, but instead should be subclassed and the subclass should override the createConn() method to provide a connection type that is supported by the subclass.
onConnected: () => void
onDisconnected: () => void
onReconnecting: () => void
autoReconnect: boolean
clientIdPrefix
keepAlive
numberOfRetries
protocolLevel
connectPacket: ConnectPacket
connectionState: TConnectionState
ctx: Context
connect(params?: ConnectParameters): Promise<TAuthenticationResult>
Connects to the MQTT broker
createConn(): Promise<SockConn>
Creates a new connection to the MQTT broker
disconnect(): Promise<void>
Disconnects from the MQTT broker
Handles the connection process including retries and reconnection
messages(): AsyncIterable<PublishPacket>
Gets an async iterator for received messages
publish(params: PublishParameters): Promise<void>
Publishes a message to the MQTT broker
subscribe(params: SubscribeParameters): Promise<void>
Subscribes to topics on the MQTT broker