Class DisconnectPacket.DisconnectPacketBuilder

  • Enclosing class:
    DisconnectPacket

    public static final class DisconnectPacket.DisconnectPacketBuilder
    extends java.lang.Object
    A class to that allows for the creation of a DisconnectPacket. Set all of the settings you want in the packet and then use the build() function to get a DisconnectPacket populated with the settings defined in the builder.
    • Constructor Detail

      • DisconnectPacketBuilder

        public DisconnectPacketBuilder()
        Creates a new DisconnectPacketBuilder so a DisconnectPacket can be created.
    • Method Detail

      • withSessionExpiryIntervalSeconds

        public DisconnectPacket.DisconnectPacketBuilder withSessionExpiryIntervalSeconds​(long sessionExpiryIntervalSeconds)
        Sets the change to the session expiry interval negotiated at connection time as part of the disconnect. Only valid for DisconnectPackets sent from client to server. It is not valid to attempt to change session expiry from zero to a non-zero value. See MQTT5 Session Expiry Interval
        Parameters:
        sessionExpiryIntervalSeconds - the session expiry interval negotiated at connection time as part of the disconnect
        Returns:
        The DisconnectPacketBuilder after setting the session expiry interval.
      • withReasonString

        public DisconnectPacket.DisconnectPacketBuilder withReasonString​(java.lang.String reasonString)
        Sets the additional diagnostic information about the reason that the sender is closing the connection See MQTT5 Reason String
        Parameters:
        reasonString - Additional diagnostic information about the reason that the sender is closing the connection
        Returns:
        The DisconnectPacketBuilder after setting the reason string.
      • withUserProperties

        public DisconnectPacket.DisconnectPacketBuilder withUserProperties​(java.util.List<UserProperty> userProperties)
        Sets the list of MQTT5 user properties included with the packet. See MQTT5 User Property
        Parameters:
        userProperties - List of MQTT5 user properties included with the packet.
        Returns:
        The DisconnectPacketBuilder after setting the user properties.
      • withServerReference

        public DisconnectPacket.DisconnectPacketBuilder withServerReference​(java.lang.String serverReference)
        Sets the property indicating an alternate server that the client may temporarily or permanently attempt to connect to instead of the configured endpoint. Will only be set if the reason code indicates another server may be used (ServerMoved, UseAnotherServer). See MQTT5 Server Reference
        Parameters:
        serverReference - Property indicating an alternate server that the client may temporarily or permanently attempt to connect to instead of the configured endpoint.
        Returns:
        The DisconnectPacketBuilder after setting the server reference.
      • build

        public DisconnectPacket build()
        Creates a new DisconnectPacket using the settings set in the builder.
        Returns:
        The DisconnectPacket created from the builder