-`function(client)` optional callback fired when PUBACK received. NOTE: When calling publish() more than once, the last callback function defined will be called for ALL publish commands.
-`function(client)` optional callback fired when PUBACK received. NOTE: When calling publish() more than once, the last callback function defined will be called for ALL publish commands.
#### Returns
#### Returns
`true` on success, `false` otherwise
`true` on success, `false` otherwise
...
@@ -213,12 +212,10 @@ Subscribes to one or several topics.
...
@@ -213,12 +212,10 @@ Subscribes to one or several topics.
#### Syntax
#### Syntax
`mqtt:subscribe(topic, qos[, function(client)])`
`mqtt:subscribe(topic, qos[, function(client)])`
`mqtt:subscribe(table[, function(client)])`
#### Parameters
#### Parameters
-`topic` a [topic string](http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices)
-`topic` a [topic string](http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices)
-`qos` QoS subscription level, default 0
-`qos` QoS subscription level, default 0
-`table` array of 'topic, qos' pairs to subscribe to
-`function(client)` optional callback fired when subscription(s) succeeded. NOTE: When calling subscribe() more than once, the last callback function defined will be called for ALL subscribe commands.
-`function(client)` optional callback fired when subscription(s) succeeded. NOTE: When calling subscribe() more than once, the last callback function defined will be called for ALL subscribe commands.
#### Returns
#### Returns
...
@@ -228,14 +225,11 @@ Subscribes to one or several topics.
...
@@ -228,14 +225,11 @@ Subscribes to one or several topics.
Rather than calling `subscribe` multiple times you should use the multiple topics syntax shown in the above example if you want to subscribe to more than one topic at once.
Rather than calling `subscribe` multiple times in a row, you should call the next `subscribe` from within the callback of the previous. A generic example is provided in [mqtt_helpers.lua](../../lua_examples/mqtt/mqtt_helpers.lua).
## mqtt.client:unsubscribe()
## mqtt.client:unsubscribe()
...
@@ -243,18 +237,14 @@ Unsubscribes from one or several topics.
...
@@ -243,18 +237,14 @@ Unsubscribes from one or several topics.
#### Syntax
#### Syntax
`mqtt:unsubscribe(topic[, function(client)])`
`mqtt:unsubscribe(topic[, function(client)])`
`mqtt:unsubscribe(table[, function(client)])`
#### Parameters
#### Parameters
-`topic` a [topic string](http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices)
-`topic` a [topic string](http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices)
-`table` array of 'topic, anything' pairs to unsubscribe from
-`function(client)` optional callback fired when unsubscription(s) succeeded. NOTE: When calling unsubscribe() more than once, the last callback function defined will be called for ALL unsubscribe commands.
-`function(client)` optional callback fired when unsubscription(s) succeeded. NOTE: When calling unsubscribe() more than once, the last callback function defined will be called for ALL unsubscribe commands.
!!! caution
!!! caution
The `mqtt:unsubscribe(table,...)` function is unimplented at this time as
Rather than calling `unsubscribe` multiple times in a row, you should call the next `unsubscribe` from within the callback of the previous. A generic example is provided in [mqtt_helpers.lua](../../lua_examples/mqtt/mqtt_helpers.lua).
the underlying MQTT library does not natively support this model. You must
subscribe and unsubsribe from topic individually.
#### Returns
#### Returns
`true` on success, `false` otherwise
`true` on success, `false` otherwise
...
@@ -263,7 +253,4 @@ Unsubscribes from one or several topics.
...
@@ -263,7 +253,4 @@ Unsubscribes from one or several topics.