public interface MqttClient
| Modifier and Type | Method and Description |
|---|---|
String |
clientId() |
MqttClient |
closeHandler(io.vertx.core.Handler<Void> closeHandler)
Set a handler that will be called when the connection with server is closed
|
MqttClient |
connect(int port,
String host,
io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.mqtt.messages.MqttConnAckMessage>> connectHandler)
Connects to an MQTT server calling connectHandler after connection
|
MqttClient |
connect(int port,
String host,
String serverName,
io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.mqtt.messages.MqttConnAckMessage>> connectHandler)
Connects to an MQTT server calling connectHandler after connection
|
static MqttClient |
create(io.vertx.core.Vertx vertx)
Return an MQTT client instance using the default options
|
static MqttClient |
create(io.vertx.core.Vertx vertx,
io.vertx.mqtt.MqttClientOptions options)
Return an MQTT client instance
|
MqttClient |
disconnect()
Disconnects from the MQTT server
|
MqttClient |
disconnect(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> disconnectHandler)
Disconnects from the MQTT server calling disconnectHandler after
disconnection
|
MqttClient |
exceptionHandler(io.vertx.core.Handler<Throwable> handler)
Set an exception handler for the client, that will be called when an error
happens in internal netty structures.
|
boolean |
isConnected() |
MqttClient |
ping()
This method is needed by the client in order to avoid server closes the
connection due to the keep alive timeout if client has no messages to send
|
MqttClient |
pingResponseHandler(io.vertx.core.Handler<Void> pingResponseHandler)
Sets handler which will be called after PINGRESP packet receiving
|
MqttClient |
publish(String topic,
io.vertx.core.buffer.Buffer payload,
io.netty.handler.codec.mqtt.MqttQoS qosLevel,
boolean isDup,
boolean isRetain)
Sends the PUBLISH message to the remote MQTT server
|
MqttClient |
publish(String topic,
io.vertx.core.buffer.Buffer payload,
io.netty.handler.codec.mqtt.MqttQoS qosLevel,
boolean isDup,
boolean isRetain,
io.vertx.core.Handler<io.vertx.core.AsyncResult<Integer>> publishSentHandler)
Sends the PUBLISH message to the remote MQTT server
|
MqttClient |
publishCompletionHandler(io.vertx.core.Handler<Integer> publishCompletionHandler)
Sets handler which will be called each time publish is completed
|
MqttClient |
publishHandler(io.vertx.core.Handler<io.vertx.mqtt.messages.MqttPublishMessage> publishHandler)
Sets handler which will be called each time server publish something to
client
|
MqttClient |
subscribe(Map<String,Integer> topics)
Subscribes to the topics with related QoS levels
|
MqttClient |
subscribe(Map<String,Integer> topics,
io.vertx.core.Handler<io.vertx.core.AsyncResult<Integer>> subscribeSentHandler)
Subscribes to the topic and adds a handler which will be called after the
request is sent
|
MqttClient |
subscribe(String topic,
int qos)
Subscribes to the topic with a specified QoS level
|
MqttClient |
subscribe(String topic,
int qos,
io.vertx.core.Handler<io.vertx.core.AsyncResult<Integer>> subscribeSentHandler)
Subscribes to the topic with a specified QoS level
|
MqttClient |
subscribeCompletionHandler(io.vertx.core.Handler<io.vertx.mqtt.messages.MqttSubAckMessage> subscribeCompletionHandler)
Sets handler which will be called after SUBACK packet receiving
|
MqttClient |
unsubscribe(String topic)
Unsubscribe from receiving messages on given topic
|
MqttClient |
unsubscribe(String topic,
io.vertx.core.Handler<io.vertx.core.AsyncResult<Integer>> unsubscribeSentHandler)
Unsubscribe from receiving messages on given topic
|
MqttClient |
unsubscribeCompletionHandler(io.vertx.core.Handler<Integer> unsubscribeCompletionHandler)
Sets handler which will be called after UNSUBACK packet receiving
|
static MqttClient create(io.vertx.core.Vertx vertx, io.vertx.mqtt.MqttClientOptions options)
vertx - Vert.x instanceoptions - MQTT client optionsstatic MqttClient create(io.vertx.core.Vertx vertx)
vertx - Vert.x instanceMqttClient connect(int port, String host, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.mqtt.messages.MqttConnAckMessage>> connectHandler)
port - port of the MQTT serverhost - hostname/ip address of the MQTT serverconnectHandler - handler called when the asynchronous connect call endsMqttClient connect(int port, String host, String serverName, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.mqtt.messages.MqttConnAckMessage>> connectHandler)
port - port of the MQTT serverhost - hostname/ip address of the MQTT serverserverName - the SNI server nameconnectHandler - handler called when the asynchronous connect call endsMqttClient disconnect()
MqttClient disconnect(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> disconnectHandler)
disconnectHandler - handler called when asynchronous disconnect call endsMqttClient publish(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain)
topic - topic on which the message is publishedpayload - message payloadqosLevel - QoS levelisDup - if the message is a duplicateisRetain - if the message needs to be retainedMqttClient publish(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain, io.vertx.core.Handler<io.vertx.core.AsyncResult<Integer>> publishSentHandler)
topic - topic on which the message is publishedpayload - message payloadqosLevel - QoS levelisDup - if the message is a duplicateisRetain - if the message needs to be retainedpublishSentHandler - handler called after PUBLISH packet sent with packetid (not when
QoS 0)MqttClient publishCompletionHandler(io.vertx.core.Handler<Integer> publishCompletionHandler)
publishCompletionHandler - handler called with the packetIdMqttClient publishHandler(io.vertx.core.Handler<io.vertx.mqtt.messages.MqttPublishMessage> publishHandler)
publishHandler - handler to callMqttClient subscribeCompletionHandler(io.vertx.core.Handler<io.vertx.mqtt.messages.MqttSubAckMessage> subscribeCompletionHandler)
subscribeCompletionHandler - handler to call. List inside is a granted QoS arrayMqttClient subscribe(String topic, int qos)
topic - topic you subscribe onqos - QoS levelMqttClient subscribe(String topic, int qos, io.vertx.core.Handler<io.vertx.core.AsyncResult<Integer>> subscribeSentHandler)
topic - topic you subscribe onqos - QoS levelsubscribeSentHandler - handler called after SUBSCRIBE packet sent with packetidMqttClient subscribe(Map<String,Integer> topics)
topics - topics and related QoS levels to subscribe toMqttClient subscribe(Map<String,Integer> topics, io.vertx.core.Handler<io.vertx.core.AsyncResult<Integer>> subscribeSentHandler)
topics - topics you subscribe onsubscribeSentHandler - handler called after SUBSCRIBE packet sent with packetidMqttClient unsubscribeCompletionHandler(io.vertx.core.Handler<Integer> unsubscribeCompletionHandler)
unsubscribeCompletionHandler - handler to call with the packetidMqttClient unsubscribe(String topic)
topic - Topic you want to unsubscribe fromMqttClient unsubscribe(String topic, io.vertx.core.Handler<io.vertx.core.AsyncResult<Integer>> unsubscribeSentHandler)
topic - Topic you want to unsubscribe fromunsubscribeSentHandler - handler called after UNSUBSCRIBE packet sentMqttClient pingResponseHandler(io.vertx.core.Handler<Void> pingResponseHandler)
pingResponseHandler - handler to callMqttClient exceptionHandler(io.vertx.core.Handler<Throwable> handler)
io.netty.handler.codec.DecoderException can be one of the causehandler - the exception handlerMqttClient closeHandler(io.vertx.core.Handler<Void> closeHandler)
closeHandler - handler to callMqttClient ping()
String clientId()
boolean isConnected()
Copyright © 2017. All rights reserved.