$k. MQTTClient

new MQTTClient(url, qosopt)

Creates a new MQTTClient

Parameters:
NameTypeAttributesDescription
urlstring

URL of the broker

qosnumber<optional>

Default quality of service

Methods

asyncPublish(payload, topic, qos)

Publish the data in a background process. Returns immediately

Parameters:
NameTypeDescription
payloadobject
topicstring
qosnumber
Since
  • 5.2.2
See
  • MQQTClient#publish

publish(payload, topic, qos, urlopt) → {boolean}

Publish something (bytes, string, js-object) under the given topic with optional quality of service (default is 0).

Parameters:
NameTypeAttributesDescription
payloadobject

payload to be published will be stringified and/or utf-8 encoded for transport

topicstring

topic to be published to

qosnumber

quality of service (0,1,2) - default is 0

urlstring<optional>

deprecated, pass the URL in the constructor

Since
  • 5.2.0
Returns:

returns true if publish succesful, false otherwise

Type: 
boolean