Class MqttClientSessionImpl
- java.lang.Object
-
- io.smallrye.reactive.messaging.mqtt.session.impl.MqttClientSessionImpl
-
- All Implemented Interfaces:
MqttClientSession
public class MqttClientSessionImpl extends Object implements MqttClientSession
-
-
Constructor Summary
Constructors Constructor Description MqttClientSessionImpl(io.vertx.core.Vertx vertx, MqttClientSessionOptions options)Create a new instance, which is not started.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MqttClientSessionexceptionHandler(io.vertx.core.Handler<Throwable> exceptionHandler)Sets handler which will be called in case of an exceptionSessionStategetState()Get the current session state.SubscriptionStategetSubscriptionState(String topicFilter)Get a current subscription state.MqttClientSessionmessageHandler(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 serverMqttClientSessionpublishCompletionExpirationHandler(io.vertx.core.Handler<Integer> publishCompletionExpirationHandler)Set the publish completion expiration handler.MqttClientSessionpublishCompletionHandler(io.vertx.core.Handler<Integer> publishCompleteHandler)Set the publish complete handler.MqttClientSessionpublishCompletionUnknownPacketIdHandler(io.vertx.core.Handler<Integer> publishCompletionUnknownPacketIdHandler)Set the publish completion unknown packet id handler.MqttClientSessionsessionStateHandler(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.MqttClientSessionsubscriptionStateHandler(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-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.smallrye.reactive.messaging.mqtt.session.MqttClientSession
isConnected, publish
-
-
-
-
Constructor Detail
-
MqttClientSessionImpl
public MqttClientSessionImpl(io.vertx.core.Vertx vertx, MqttClientSessionOptions options)Create a new instance, which is not started.- Parameters:
vertx- The vert.x instance to use.options- The client session options.
-
-
Method Detail
-
start
public io.vertx.core.Future<Void> start()
Description copied from interface:MqttClientSessionStart the session. This will try to drive the connection toSessionState.CONNECTED.- Specified by:
startin interfaceMqttClientSession
-
stop
public io.vertx.core.Future<Void> stop()
Description copied from interface:MqttClientSessionStop the session. This will try to drive the connection toSessionState.DISCONNECTED.- Specified by:
stopin interfaceMqttClientSession
-
getState
public SessionState getState()
Description copied from interface:MqttClientSessionGet the current session state.- Specified by:
getStatein interfaceMqttClientSession- Returns:
- The current state.
-
getSubscriptionState
public SubscriptionState getSubscriptionState(String topicFilter)
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
public io.vertx.core.Future<Integer> subscribe(String topic, RequestedQoS qos)
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
public io.vertx.core.Future<Void> unsubscribe(String topic)
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
public MqttClientSession exceptionHandler(io.vertx.core.Handler<Throwable> 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)
-
-