public interface MqttClientSession
Modifier and Type | Method and Description |
---|---|
static MqttClientSession |
create(io.vertx.core.Vertx vertx,
MqttClientSessionOptions options)
Create a new MQTT client session.
|
MqttClientSession |
exceptionHandler(io.vertx.core.Handler<Throwable> exceptionHandler)
Sets handler which will be called in case of an exception
|
SessionState |
getState()
Get the current session state.
|
SubscriptionState |
getSubscriptionState(String topicFilter)
Get a current subscription state.
|
default boolean |
isConnected()
Check if the session is currently connected.
|
MqttClientSession |
messageHandler(io.vertx.core.Handler<io.vertx.mqtt.messages.MqttPublishMessage> messageHandler)
Sets handler which will be called each time server publish something to client
|
default io.vertx.core.Future<Integer> |
publish(String topic,
io.vertx.core.buffer.Buffer payload,
io.netty.handler.codec.mqtt.MqttQoS qosLevel)
Sends the PUBLISH message to the remote MQTT server
|
io.vertx.core.Future<Integer> |
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
|
MqttClientSession |
publishCompletionExpirationHandler(io.vertx.core.Handler<Integer> publishCompletionExpirationHandler)
Set the publish completion expiration handler.
|
MqttClientSession |
publishCompletionHandler(io.vertx.core.Handler<Integer> publishCompleteHandler)
Set the publish complete handler.
|
MqttClientSession |
publishCompletionUnknownPacketIdHandler(io.vertx.core.Handler<Integer> publishCompletionUnknownPacketIdHandler)
Set the publish completion unknown packet id handler.
|
MqttClientSession |
sessionStateHandler(io.vertx.core.Handler<SessionEvent> sessionStateHandler)
Set the session state handler.
|
io.vertx.core.Future<Void> |
start()
Start the session.
|
io.vertx.core.Future<Void> |
stop()
Stop the session.
|
io.vertx.core.Future<Integer> |
subscribe(String topic,
RequestedQoS qos)
Subscribes to a single topic with related QoS level.
|
MqttClientSession |
subscriptionStateHandler(io.vertx.core.Handler<SubscriptionEvent> subscriptionStateHandler)
Set the subscription state handler.
|
io.vertx.core.Future<Void> |
unsubscribe(String topic)
Unsubscribe from receiving messages on given topic
|
static MqttClientSession create(io.vertx.core.Vertx vertx, MqttClientSessionOptions options)
The session will initially be disconnected, and must be started using start()
.
vertx
- Vert.x instanceoptions
- MQTT client session optionsMqttClientSession sessionStateHandler(io.vertx.core.Handler<SessionEvent> sessionStateHandler)
sessionStateHandler
- The new handler, will overwrite the old one.MqttClientSession subscriptionStateHandler(io.vertx.core.Handler<SubscriptionEvent> subscriptionStateHandler)
subscriptionStateHandler
- The new handler, will overwrite the old one.MqttClientSession publishCompletionHandler(io.vertx.core.Handler<Integer> publishCompleteHandler)
publishCompleteHandler
- The new handler, will overwrite the old one.MqttClient.publishCompletionHandler(Handler)
MqttClientSession publishCompletionExpirationHandler(io.vertx.core.Handler<Integer> publishCompletionExpirationHandler)
publishCompletionExpirationHandler
- The new handler, will overwrite the old one.MqttClient.publishCompletionExpirationHandler(Handler)
MqttClientSession publishCompletionUnknownPacketIdHandler(io.vertx.core.Handler<Integer> publishCompletionUnknownPacketIdHandler)
publishCompletionUnknownPacketIdHandler
- The new handler, will overwrite the old one.MqttClient.publishCompletionUnknownPacketIdHandler(Handler)
io.vertx.core.Future<Void> start()
SessionState.CONNECTED
.io.vertx.core.Future<Void> stop()
SessionState.DISCONNECTED
.SessionState getState()
SubscriptionState getSubscriptionState(String topicFilter)
topicFilter
- The topic filter to get the state for.default boolean isConnected()
true
if the session is currently connected, false
otherwise.io.vertx.core.Future<Integer> subscribe(String topic, RequestedQoS qos)
topic
- The topic to subscribe to.qos
- The QoS to request from the server.io.vertx.core.Future<Void> unsubscribe(String topic)
topic
- Topic you want to unsubscribe fromMqttClientSession messageHandler(io.vertx.core.Handler<io.vertx.mqtt.messages.MqttPublishMessage> messageHandler)
messageHandler
- handler to callMqttClientSession exceptionHandler(io.vertx.core.Handler<Throwable> exceptionHandler)
exceptionHandler
- handler to callio.vertx.core.Future<Integer> 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 retainedFuture
completed after PUBLISH packet sent with packetid (not when QoS 0)default io.vertx.core.Future<Integer> publish(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel)
topic
- topic on which the message is publishedpayload
- message payloadqosLevel
- QoS levelFuture
completed after PUBLISH packet sent with packetid (not when QoS 0)Copyright © 2018–2021 SmallRye. All rights reserved.