Class MqttConnectedContext


  • public final class MqttConnectedContext
    extends Object
    Context delivered to high-level client connection callbacks.

    The context contains the MQTT details that are known after CONNACK has been accepted. It is immutable so application callbacks can safely keep it after the callback method returns.

    • Constructor Detail

      • MqttConnectedContext

        public MqttConnectedContext​(String clientId,
                                    PlccomMqttProtocolVersion requestedProtocolVersion,
                                    PlccomMqttProtocolVersion negotiatedProtocolVersion,
                                    boolean sessionPresent)
        Creates an immutable connected-context value.
        Parameters:
        clientId - MQTT Client Identifier used by the connection
        requestedProtocolVersion - version requested by the caller, possibly PlccomMqttProtocolVersion.AUTO
        negotiatedProtocolVersion - concrete MQTT version accepted by the broker
        sessionPresent - true when CONNACK reported an existing session
        Throws:
        NullPointerException - if clientId, requestedProtocolVersion or negotiatedProtocolVersion is null
    • Method Detail

      • clientId

        public String clientId()
        Returns the MQTT Client Identifier used by the connection.
        Returns:
        MQTT Client Identifier
      • negotiatedProtocolVersion

        public PlccomMqttProtocolVersion negotiatedProtocolVersion()
        Returns the concrete protocol version accepted by the broker.
        Returns:
        negotiated MQTT version
      • sessionPresent

        public boolean sessionPresent()
        Returns whether the broker reported an existing session.
        Returns:
        true when CONNACK Session Present was set