Class ConnAck

java.lang.Object
org.mqtt4j.hato.ConnAck

public final class ConnAck extends Object
The broker's successful connection acknowledgement, with the limits that the broker announced for the connection. MQTT 3.1.1 brokers announce none, so a 3.1.1 connection reports the values that MQTT 5.0 assumes when a limit is not announced: QoS 2, retained messages and wildcard and shared subscriptions available, and the largest packet that MQTT allows.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the number of the connection attempt that this acknowledgement established.
    boolean
    equals(@Nullable Object other)
     
    int
     
    int
    Returns the largest packet, in bytes including the fixed header, that the broker accepts on this connection.
    Returns the highest QoS at which the broker accepts publications on this connection.
    static ConnAck
    of(boolean sessionPresent, long connectionAttempt)
    Describes a successful acknowledgement of connection attempt number connectionAttempt, and whether the broker resumed a session, from a broker that announced no limits.
    boolean
    Returns whether the broker accepts publications with the retain flag on this connection.
    boolean
    Returns whether the broker resumed an existing session.
    boolean
    Returns whether the broker accepts shared subscriptions.
     
    boolean
    Returns whether the broker accepts subscriptions whose filters contain wildcards.
    withMaximumPacketSize(int maximumPacketSize)
    Returns a copy with a different largest packet that the broker accepts.
    withMaximumQos(Qos maximumQos)
    Returns a copy with a different highest QoS at which the broker accepts publications.
    withRetainAvailable(boolean retainAvailable)
    Returns a copy with a different answer to whether the broker accepts retained publications.
    withSharedSubscriptionAvailable(boolean sharedSubscriptionAvailable)
    Returns a copy with a different answer to whether the broker accepts shared subscriptions.
    withWildcardSubscriptionAvailable(boolean wildcardSubscriptionAvailable)
    Returns a copy with a different answer to whether the broker accepts wildcard subscriptions.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • of

      public static ConnAck of(boolean sessionPresent, long connectionAttempt)
      Describes a successful acknowledgement of connection attempt number connectionAttempt, and whether the broker resumed a session, from a broker that announced no limits. The with methods describe the limits that a broker announced.
      Parameters:
      sessionPresent - whether the broker resumed an existing session
      connectionAttempt - the number of the connection attempt that this acknowledgement established
      Returns:
      the acknowledgement, with the values that MQTT 5.0 assumes for limits that are not
      announced
      
      Throws:
      IllegalArgumentException -
      if `connectionAttempt` is not positive
      
    • withMaximumQos

      public ConnAck withMaximumQos(Qos maximumQos)
      Returns a copy with a different highest QoS at which the broker accepts publications.
      Parameters:
      maximumQos - the highest QoS at which the broker accepts publications
      Returns:
      a copy with a different highest QoS at which the broker accepts publications
    • withRetainAvailable

      public ConnAck withRetainAvailable(boolean retainAvailable)
      Returns a copy with a different answer to whether the broker accepts retained publications.
      Parameters:
      retainAvailable - whether the broker accepts retained publications
      Returns:
      a copy with a different answer to whether the broker accepts retained publications
    • withWildcardSubscriptionAvailable

      public ConnAck withWildcardSubscriptionAvailable(boolean wildcardSubscriptionAvailable)
      Returns a copy with a different answer to whether the broker accepts wildcard subscriptions.
      Parameters:
      wildcardSubscriptionAvailable - whether the broker accepts wildcard subscriptions
      Returns:
      a copy with a different answer to whether the broker accepts wildcard subscriptions
    • withSharedSubscriptionAvailable

      public ConnAck withSharedSubscriptionAvailable(boolean sharedSubscriptionAvailable)
      Returns a copy with a different answer to whether the broker accepts shared subscriptions.
      Parameters:
      sharedSubscriptionAvailable - whether the broker accepts shared subscriptions
      Returns:
      a copy with a different answer to whether the broker accepts shared subscriptions
    • withMaximumPacketSize

      public ConnAck withMaximumPacketSize(int maximumPacketSize)
      Returns a copy with a different largest packet that the broker accepts.
      Parameters:
      maximumPacketSize - the largest packet, in bytes including the fixed header, that the broker accepts
      Returns:
      a copy with a different largest packet that the broker accepts
      Throws:
      IllegalArgumentException -
      if `maximumPacketSize` is not between 1 and 268435460
      
    • sessionPresent

      public boolean sessionPresent()
      Returns whether the broker resumed an existing session.
      Returns:
      whether the broker resumed an existing session
    • connectionAttempt

      public long connectionAttempt()
      Returns the number of the connection attempt that this acknowledgement established. A client numbers its attempts consecutively from 1, whether the application's MqttClient.connect() or an automatic reconnection started them.
      Returns:
      the number of the connection attempt that this acknowledgement established
    • maximumQos

      public Qos maximumQos()
      Returns the highest QoS at which the broker accepts publications on this connection.
      Returns:
      the highest QoS at which the broker accepts publications on this connection
    • retainAvailable

      public boolean retainAvailable()
      Returns whether the broker accepts publications with the retain flag on this connection.
      Returns:
      whether the broker accepts publications with the retain flag on this connection
    • wildcardSubscriptionAvailable

      public boolean wildcardSubscriptionAvailable()
      Returns whether the broker accepts subscriptions whose filters contain wildcards.
      Returns:
      whether the broker accepts subscriptions whose filters contain wildcards
    • sharedSubscriptionAvailable

      public boolean sharedSubscriptionAvailable()
      Returns whether the broker accepts shared subscriptions.
      Returns:
      whether the broker accepts shared subscriptions
    • maximumPacketSize

      public int maximumPacketSize()
      Returns the largest packet, in bytes including the fixed header, that the broker accepts on this connection.
      Returns:
      the largest packet, in bytes including the fixed header, that the broker accepts on this connection
    • equals

      public boolean equals(@Nullable Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object