Interface: MQTTCoolListener

MQTTCoolListener

Interface to be implemented for receiving events related to the creation of MQTTCoolSession instances.

The methods of this interface are invoked asynchronously upon a call of openSession. Note that it is not mandatory to implement all the interface methods, as the missing ones will be ignored; nevertheless, it is recommended to supply at least an implementation of MQTTCoolListener#onConnectionSuccess, to get the reference to the provided MQTTCoolSession instance.

To implement this interface, it is only required to create a JavaScript object as follows:

var listener = {

  onLsClient : function(lsClient) { ... },

  onConnectionSuccess : function(mqttCoolSession) { ... },

  onConnectionFailure : function(errorType, errorCode, errorMessage) { ... }
}

Method Summary

onConnectionFailure
Event handler invoked to notify that the requested connection to MQTT.Cool cannot be established.
onConnectionSuccess
Event handler invoked when a connection to MQTT.Cool is established.
onLsClient
First event handler that will be fired when the embedded LightstreamerClient instance has been created and initialized, but before the connection to MQTT.Cool is established.

Method Detail

onConnectionFailure(errorType, errorCodeopt, errorMessageopt)

Event handler invoked to notify that the requested connection to MQTT.Cool cannot be established.
Parameters:
Name Type Argument Description
errorType string The error type, which can be one of the following:
  • SERVER_ERROR, in the case of an MQTT.Cool server specific issue.
  • UNAUTHORIZED_SESSION, when the plugged Hook denies the authorization to open a session, or raises an issue while performing its checking activities.
errorCode number <optional>
The error code, whose value depends on the errorType, as follows:
  • For SERVER_ERROR, the errorCode is one of the possible value as detailed in the documentation of ClientListener#onServerError event handler.
  • For UNAUTHORIZED_SESSION, the errorCode is given by the specific plugged Hook.
errorMessage string <optional>
The description of the error, if any.

onConnectionSuccess(mqttCoolSessionnon-null)

Event handler invoked when a connection to MQTT.Cool is established.
Parameters:
Name Type Description
mqttCoolSession MQTTCoolSession MQTTCoolSession instance to be used to create new MqttClient objects.

onLsClient(lsClientnon-null)

First event handler that will be fired when the embedded LightstreamerClient instance has been created and initialized, but before the connection to MQTT.Cool is established.

The event offers the possibility to further customize the LightstreamerClient instance just before the connection is actually issued. It can also be used to attach a ClientListener to the given instance.

Parameters:
Name Type Description
lsClient external:LightstreamerClient The client instance that will be used internally to connect to MQTT.Cool.