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 MqttClientSession
exceptionHandler(io.vertx.core.Handler<Throwable> exceptionHandler)
Sets handler which will be called in case of an exceptionSessionState
getState()
Get the current session state.SubscriptionState
getSubscriptionState(String topicFilter)
Get a current subscription state.MqttClientSession
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 serverMqttClientSession
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-
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:MqttClientSession
Start the session. This will try to drive the connection toSessionState.CONNECTED
.- Specified by:
start
in interfaceMqttClientSession
-
stop
public io.vertx.core.Future<Void> stop()
Description copied from interface:MqttClientSession
Stop the session. This will try to drive the connection toSessionState.DISCONNECTED
.- Specified by:
stop
in interfaceMqttClientSession
-
getState
public SessionState getState()
Description copied from interface:MqttClientSession
Get the current session state.- Specified by:
getState
in interfaceMqttClientSession
- Returns:
- The current state.
-
getSubscriptionState
public SubscriptionState getSubscriptionState(String topicFilter)
Description copied from interface:MqttClientSession
Get a current subscription state.- Specified by:
getSubscriptionState
in 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:MqttClientSession
Subscribes to a single topic with related QoS level.- Specified by:
subscribe
in 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:MqttClientSession
Unsubscribe from receiving messages on given topic- Specified by:
unsubscribe
in 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:MqttClientSession
Sets handler which will be called in case of an exception- Specified by:
exceptionHandler
in 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:MqttClientSession
Set the session state handler.- Specified by:
sessionStateHandler
in 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:MqttClientSession
Set the subscription state handler.- Specified by:
subscriptionStateHandler
in 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:MqttClientSession
Set the publish complete handler.- Specified by:
publishCompletionHandler
in 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:MqttClientSession
Set the publish completion expiration handler.- Specified by:
publishCompletionExpirationHandler
in 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:MqttClientSession
Set the publish completion unknown packet id handler.- Specified by:
publishCompletionUnknownPacketIdHandler
in 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:MqttClientSession
Sets handler which will be called each time server publish something to client- Specified by:
messageHandler
in 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:MqttClientSession
Sends the PUBLISH message to the remote MQTT server- Specified by:
publish
in 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
Future
completed after PUBLISH packet sent with packetid (not when QoS 0)
-
-