Class MqttClientSessionImpl
java.lang.Object
io.smallrye.reactive.messaging.mqtt.session.impl.MqttClientSessionImpl
- All Implemented Interfaces:
MqttClientSession
-
Constructor Summary
ConstructorsConstructorDescriptionMqttClientSessionImpl(io.vertx.core.Vertx vertx, MqttClientSessionOptions options) Create a new instance, which is not started. -
Method Summary
Modifier and TypeMethodDescriptionexceptionHandler(io.vertx.core.Handler<Throwable> exceptionHandler) Sets handler which will be called in case of an exceptiongetState()Get the current session state.getSubscriptionState(String topicFilter) Get a current subscription state.messageHandler(io.vertx.core.Handler<io.vertx.mqtt.messages.MqttPublishMessage> messageHandler) Sets handler which will be called each time server publish something to clientio.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 serverpublishCompletionExpirationHandler(io.vertx.core.Handler<Integer> publishCompletionExpirationHandler) Set the publish completion expiration handler.publishCompletionHandler(io.vertx.core.Handler<Integer> publishCompleteHandler) Set the publish complete handler.publishCompletionUnknownPacketIdHandler(io.vertx.core.Handler<Integer> publishCompletionUnknownPacketIdHandler) Set the publish completion unknown packet id handler.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.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 topicMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.smallrye.reactive.messaging.mqtt.session.MqttClientSession
isConnected, publish
-
Constructor Details
-
MqttClientSessionImpl
Create a new instance, which is not started.- Parameters:
vertx- The vert.x instance to use.options- The client session options.
-
-
Method Details
-
start
Description copied from interface:MqttClientSessionStart the session. This will try to drive the connection toSessionState.CONNECTED.- Specified by:
startin interfaceMqttClientSession
-
stop
Description copied from interface:MqttClientSessionStop the session. This will try to drive the connection toSessionState.DISCONNECTED.- Specified by:
stopin interfaceMqttClientSession
-
getState
Description copied from interface:MqttClientSessionGet the current session state.- Specified by:
getStatein interfaceMqttClientSession- Returns:
- The current state.
-
getSubscriptionState
Description copied from interface:MqttClientSessionGet a current subscription state.- Specified by:
getSubscriptionStatein interfaceMqttClientSession- Parameters:
topicFilter- The topic filter to get the state for.- Returns:
- The current state of the requested subscription.
-
subscribe
Description copied from interface:MqttClientSessionSubscribes to a single topic with related QoS level.- Specified by:
subscribein interfaceMqttClientSession- Parameters:
topic- The topic to subscribe to.qos- The QoS to request from the server.- Returns:
- current MQTT client session instance
-
unsubscribe
Description copied from interface:MqttClientSessionUnsubscribe from receiving messages on given topic- Specified by:
unsubscribein interfaceMqttClientSession- Parameters:
topic- Topic you want to unsubscribe from- Returns:
- current MQTT client session instance
-
exceptionHandler
Description copied from interface:MqttClientSessionSets handler which will be called in case of an exception- Specified by:
exceptionHandlerin interfaceMqttClientSession- Parameters:
exceptionHandler- handler to call- Returns:
- current MQTT client session instance
-
sessionStateHandler
public MqttClientSession sessionStateHandler(io.vertx.core.Handler<SessionEvent> sessionStateHandler) Description copied from interface:MqttClientSessionSet the session state handler.- Specified by:
sessionStateHandlerin interfaceMqttClientSession- Parameters:
sessionStateHandler- The new handler, will overwrite the old one.- Returns:
- current MQTT client session instance
-
subscriptionStateHandler
public MqttClientSession subscriptionStateHandler(io.vertx.core.Handler<SubscriptionEvent> subscriptionStateHandler) Description copied from interface:MqttClientSessionSet the subscription state handler.- Specified by:
subscriptionStateHandlerin interfaceMqttClientSession- Parameters:
subscriptionStateHandler- The new handler, will overwrite the old one.- Returns:
- current MQTT client session instance
-
publishCompletionHandler
public MqttClientSession publishCompletionHandler(io.vertx.core.Handler<Integer> publishCompleteHandler) Description copied from interface:MqttClientSessionSet the publish complete handler.- Specified by:
publishCompletionHandlerin interfaceMqttClientSession- Parameters:
publishCompleteHandler- The new handler, will overwrite the old one.- Returns:
- current MQTT client session instance
- See Also:
-
MqttClient.publishCompletionHandler(Handler)
-
publishCompletionExpirationHandler
public MqttClientSession publishCompletionExpirationHandler(io.vertx.core.Handler<Integer> publishCompletionExpirationHandler) Description copied from interface:MqttClientSessionSet the publish completion expiration handler.- Specified by:
publishCompletionExpirationHandlerin interfaceMqttClientSession- Parameters:
publishCompletionExpirationHandler- The new handler, will overwrite the old one.- Returns:
- current MQTT client session instance
- See Also:
-
MqttClient.publishCompletionExpirationHandler(Handler)
-
publishCompletionUnknownPacketIdHandler
public MqttClientSession publishCompletionUnknownPacketIdHandler(io.vertx.core.Handler<Integer> publishCompletionUnknownPacketIdHandler) Description copied from interface:MqttClientSessionSet the publish completion unknown packet id handler.- Specified by:
publishCompletionUnknownPacketIdHandlerin interfaceMqttClientSession- Parameters:
publishCompletionUnknownPacketIdHandler- The new handler, will overwrite the old one.- Returns:
- current MQTT client session instance
- See Also:
-
MqttClient.publishCompletionUnknownPacketIdHandler(Handler)
-
messageHandler
public MqttClientSession messageHandler(io.vertx.core.Handler<io.vertx.mqtt.messages.MqttPublishMessage> messageHandler) Description copied from interface:MqttClientSessionSets handler which will be called each time server publish something to client- Specified by:
messageHandlerin interfaceMqttClientSession- Parameters:
messageHandler- handler to call- Returns:
- current MQTT client session instance
-
publish
public 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) Description copied from interface:MqttClientSessionSends the PUBLISH message to the remote MQTT server- Specified by:
publishin interfaceMqttClientSession- Parameters:
topic- topic on which the message is publishedpayload- message payloadqosLevel- QoS levelisDup- if the message is a duplicateisRetain- if the message needs to be retained- Returns:
- a
Futurecompleted after PUBLISH packet sent with packetid (not when QoS 0)
-