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 Details

    • 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 Details

    • start

      public io.vertx.core.Future<Void> start()
      Description copied from interface: MqttClientSession
      Start the session. This will try to drive the connection to SessionState.CONNECTED.
      Specified by:
      start in interface MqttClientSession
    • stop

      public io.vertx.core.Future<Void> stop()
      Description copied from interface: MqttClientSession
      Stop the session. This will try to drive the connection to SessionState.DISCONNECTED.
      Specified by:
      stop in interface MqttClientSession
    • getState

      public SessionState getState()
      Description copied from interface: MqttClientSession
      Get the current session state.
      Specified by:
      getState in interface MqttClientSession
      Returns:
      The current state.
    • getSubscriptionState

      public SubscriptionState getSubscriptionState(String topicFilter)
      Description copied from interface: MqttClientSession
      Get a current subscription state.
      Specified by:
      getSubscriptionState in interface MqttClientSession
      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 interface MqttClientSession
      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 interface MqttClientSession
      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 interface MqttClientSession
      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 interface MqttClientSession
      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 interface MqttClientSession
      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 interface MqttClientSession
      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 interface MqttClientSession
      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 interface MqttClientSession
      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 interface MqttClientSession
      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 interface MqttClientSession
      Parameters:
      topic - topic on which the message is published
      payload - message payload
      qosLevel - QoS level
      isDup - if the message is a duplicate
      isRetain - if the message needs to be retained
      Returns:
      a Future completed after PUBLISH packet sent with packetid (not when QoS 0)