Browser specific MQTT5 client implementation

MQTT5 Client User Guide

Hierarchy

Implements

Constructors

Methods

  • Triggers cleanup of native resources associated with the MQTT5 client. On the browser, the implementation is an empty function.

    Returns void

  • Forces all written events to be buffered in memory. The buffered data will be flushed when uncork is called.

    Returns void

  • 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.

    Parameters

    • event: EventKey

      The name of the event

    • Rest ...args: any[]

      Event payload

    Returns boolean

  • Send a message to subscribing clients by queuing a PUBLISH packet to be sent to the server.

    Parameters

    Returns Promise<PublishCompletionResult>

    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 maintain connectivity to the configured endpoint. The client will attempt to stay connected using the properties of the reconnect-related parameters in the mqtt5 client configuration.

    This is an asynchronous operation.

    Returns void

  • 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.

    Parameters

    • Optional disconnectPacket: DisconnectPacket

      (optional) properties of a DISCONNECT packet to send as part of the shutdown process

    Returns void

  • Subscribe to one or more topic filters by queuing a SUBSCRIBE packet to be sent to the server.

    Parameters

    Returns Promise<SubackPacket>

    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.

    Returns void

  • Unsubscribe from one or more topic filters by queuing an UNSUBSCRIBE packet to be sent to the server.

    Parameters

    Returns Promise<UnsubackPacket>

    a promise that will be rejected with an error or resolved with the UNSUBACK response

Browser-only

INFO: string = 'info'

Event 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.

    Parameters

    • event: "error"

      the type of event to listen to

    • listener: ErrorEventListener

      the event listener to add

    Returns Mqtt5Client

  • 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.

    Parameters

    • event: "info"

      the type of event to listen to

    • listener: ErrorEventListener

      the event listener to add

    Returns Mqtt5Client

  • Registers a listener for the client's messageReceived event. A messageReceived event is emitted when an MQTT PUBLISH packet is received by the client.

    Parameters

    Returns Mqtt5Client

  • Registers a listener for the client's attemptingConnect event. A attemptingConnect event is emitted every time the client begins a connection attempt.

    Parameters

    Returns Mqtt5Client

  • Registers a listener for the client's connectionSuccess event. A connectionSuccess event is emitted every time the client successfully establishes an MQTT connection.

    Parameters

    Returns Mqtt5Client

  • Registers a listener for the client's connectionFailure event. A connectionFailure event is emitted every time the client fails to establish an MQTT connection.

    Parameters

    Returns Mqtt5Client

  • 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.

    Parameters

    Returns Mqtt5Client

  • 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.

    Parameters

    • event: "stopped"

      the type of event to listen to

    • listener: StoppedEventListener

      the event listener to add

    Returns Mqtt5Client

Events

ATTEMPTING_CONNECT: string = 'attemptingConnect'

Event emitted when the client begins a connection attempt.

Listener type: AttemptingConnectEventListener

CONNECTION_FAILURE: string = 'connectionFailure'

Event emitted when the client fails to establish an MQTT connection. Only emitted after an attemptingConnect event.

Listener type: ConnectionFailureEventListener

CONNECTION_SUCCESS: string = 'connectionSuccess'

Event emitted when the client successfully establishes an MQTT connection. Only emitted after an attemptingConnect event.

Listener type: ConnectionSuccessEventListener

DISCONNECTION: string = 'disconnection'

Event emitted when the client's current connection is closed for any reason. Only emitted after a connectionSuccess event.

Listener type: DisconnectionEventListener

ERROR: string = 'error'

Event emitted when the client encounters a disruptive error condition. Not currently used.

Listener type: ErrorEventListener

INFO: string = 'info'

Event 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

MESSAGE_RECEIVED: string = 'messageReceived'

Event emitted when an MQTT PUBLISH packet is received by the client.

Listener type: MessageReceivedEventListener

STOPPED: string = 'stopped'

Event emitted when the client finishes shutdown as a result of the user invoking stop.

Listener type: StoppedEventListener

Generated using TypeDoc