Client constructor
The configuration for this client
Forces all written events to be buffered in memory. The buffered data will be flushed when uncork is called.
Synchronously calls each of the listeners registered for the event key supplied in registration order. If the BufferedEventEmitter is currently corked, the event will be buffered until uncork is called.
The name of the event
Rest
...args: any[]Event payload
Send a message to subscribing clients by queuing a PUBLISH packet to be sent to the server.
PUBLISH packet to send to the server
a promise that will be rejected with an error or resolved with the PUBACK response (QoS 1), or undefined (QoS 0)
Notifies the MQTT5 client that you want it to end connectivity to the configured endpoint, disconnecting any existing connection and halting reconnection attempts.
This is an asynchronous operation. Once the process completes, no further events will be emitted until the client has start invoked. Invoking start() after a stop() will always result in a new MQTT session.
Optional
disconnectPacket: DisconnectPacket(optional) properties of a DISCONNECT packet to send as part of the shutdown process
Subscribe to one or more topic filters by queuing a SUBSCRIBE packet to be sent to the server.
SUBSCRIBE packet to send to the server
a promise that will be rejected with an error or resolved with the SUBACK response
Flushes all data buffered since cork was called.
NOTE: It is HIGHLY recommended that uncorking should always be done via
process.nextTick
, not during the EventEmitter.on()
call.
Unsubscribe from one or more topic filters by queuing an UNSUBSCRIBE packet to be sent to the server.
UNSUBSCRIBE packet to send to the server
a promise that will be rejected with an error or resolved with the UNSUBACK response
Static
INFOEvent emitted when the client encounters a transient error event that will not disrupt promises based on lifecycle events. Currently, mqtt-js client error events are relayed to this event.
Listener type: ErrorEventListener
Registers a listener for the client's error event. An error event is emitted when the client encounters a disruptive error condition.
the type of event to listen to
the event listener to add
Registers a listener for the client's info event. An info event is emitted when the client encounters a transient error event that will not disrupt promises based on lifecycle events. Currently, mqtt-js client error events are relayed to this event.
the type of event to listen to
the event listener to add
Registers a listener for the client's messageReceived event. A messageReceived event is emitted when an MQTT PUBLISH packet is received by the client.
the type of event to listen to
the event listener to add
Registers a listener for the client's attemptingConnect event. A attemptingConnect event is emitted every time the client begins a connection attempt.
the type of event to listen to
the event listener to add
Registers a listener for the client's connectionSuccess event. A connectionSuccess event is emitted every time the client successfully establishes an MQTT connection.
the type of event to listen to
the event listener to add
Registers a listener for the client's connectionFailure event. A connectionFailure event is emitted every time the client fails to establish an MQTT connection.
the type of event to listen to
the event listener to add
Registers a listener for the client's disconnection event. A disconnection event is emitted when the client's current MQTT connection is closed for any reason.
the type of event to listen to
the event listener to add
Registers a listener for the client's stopped event. A stopped event is emitted when the client finishes shutdown as a result of the user invoking stop.
the type of event to listen to
the event listener to add
Static
ATTEMPTING_Event emitted when the client begins a connection attempt.
Listener type: AttemptingConnectEventListener
Static
CONNECTION_Event emitted when the client fails to establish an MQTT connection. Only emitted after an attemptingConnect event.
Listener type: ConnectionFailureEventListener
Static
CONNECTION_Event emitted when the client successfully establishes an MQTT connection. Only emitted after an attemptingConnect event.
Listener type: ConnectionSuccessEventListener
Static
DISCONNECTIONEvent emitted when the client's current connection is closed for any reason. Only emitted after a connectionSuccess event.
Listener type: DisconnectionEventListener
Static
ERROREvent emitted when the client encounters a disruptive error condition. Not currently used.
Listener type: ErrorEventListener
Static
INFOEvent emitted when the client encounters a transient error event that will not disrupt promises based on lifecycle events. Currently, mqtt-js client error events are relayed to this event.
Listener type: ErrorEventListener
Static
MESSAGE_Event emitted when an MQTT PUBLISH packet is received by the client.
Listener type: MessageReceivedEventListener
Static
STOPPEDEvent emitted when the client finishes shutdown as a result of the user invoking stop.
Listener type: StoppedEventListener
Generated using TypeDoc
Browser specific MQTT5 client implementation
MQTT5 Client User Guide