Constructor
new MASPluginMQTTClient(clientId, masMQTTConstants)
Parameters:
| Name |
Type |
Description |
clientId |
string
|
Unique broker-client ID for this client. Default clientId is the one picked from msso_config.json |
masMQTTConstants |
MASPluginMQTTConstants
|
An instance of populated MASPluginMQTTConstants object. |
- Source:
Methods
connect(successHandler, errorHandler)
Connects to a message broker using the MASPluginMQTTConstants that is provided during construction of this object.
Parameters:
| Name |
Type |
Description |
successHandler |
successCallbackFunction
|
user defined success callback that is invoked on success scenario. |
errorHandler |
errorCallbackFunction
|
user defined error callback that is invoked on failure scenario. |
- Source:
disconnect(successHandler, errorHandler)
Disconnects from the connected message broker
Parameters:
| Name |
Type |
Description |
successHandler |
successCallbackFunction
|
user defined success callback that is invoked on success scenario. |
errorHandler |
errorCallbackFunction
|
user defined error callback that is invoked on failure scenario. |
- Source:
isConnected(successHandler, errorHandler)
Checks if device is connected to the MQTT broker.
Parameters:
| Name |
Type |
Description |
successHandler |
successCallbackFunction
|
user defined success callback that is invoked on success scenario. |
errorHandler |
errorCallbackFunction
|
user defined error callback that is invoked on failure scenario. |
- Source:
publish(successHandler, errorHandler, topicName, message, QoS, retain)
Publish to a topic via the connected MQTT broker.
Parameters:
| Name |
Type |
Description |
successHandler |
successCallbackFunction
|
user defined success callback that is invoked on success scenario. |
errorHandler |
errorCallbackFunction
|
user defined error callback that is invoked on failure scenario. |
topicName |
string
|
topic to which the user sends the message |
message |
string
|
specifies the message to be sent. The message bytes should be a base64 encoded string to support sending images |
QoS |
integer
|
Quality of Service for message delivery.0-> At most once,1-> At least once, 2: Exactly once. Default is 2 |
retain |
boolean
|
indication for the broker to persist the messages for a client |
- Source:
subscribe(successHandler, errorHandler, topicName, QoS)
Subscribes to a topic via the connected MQTT broker.
Parameters:
- Source:
unsubscribe(successHandler, errorHandler, topicName)
Unsubscribe from a topic
Parameters:
| Name |
Type |
Description |
successHandler |
successCallbackFunction
|
user defined success callback that is invoked on success scenario. |
errorHandler |
errorCallbackFunction
|
user defined error callback that is invoked on failure scenario. |
topicName |
string
|
topic to which the user needs to unsubscribe. |
- Source: