Interface ModifiableSubackPacket

  • All Superinterfaces:
    SubackPacket

    @DoNotImplement
    public interface ModifiableSubackPacket
    extends SubackPacket
    A SubackPacket that can be modified before it is sent to the client.

    For MQTT 3 clients you should only modify the reason codes, as the other properties exists only since MQTT 5 and will therefore not be send to an MQTT 3 client.

    Since:
    4.3.0, CE 2020.1
    • Method Detail

      • setReasonCodes

        void setReasonCodes​(@NotNull List<@NotNull SubackReasonCode> reasonCodes)
        Sets the list of reason codes of the SUBACK packet.

        MQTT 3.x clients know less SUBACK reason codes than MQTT 5 clients. See SubackReasonCode how HiveMQ will transform the unknown reason codes for MQTT 3.x clients.

        Parameters:
        reasonCodes - The list of reason codes to be written into the SUBACK packet.
        Throws:
        NullPointerException - If the list or an individual reason code is null.
        IllegalArgumentException - If the amount of reason codes passed differs from that contained in the packet being manipulated.
        IllegalStateException - If switching from successful reason code to unsuccessful reason code or vice versa. Check out SubackReasonCode to see what reason code counts as a success or unsuccessful code.
        Since:
        4.3.0, CE 2020.1
      • setReasonString

        void setReasonString​(@Nullable String reasonString)
        Sets the reason string of the SUBACK packet.

        This setting is only respected for MQTT 5 clients and ignored for MQTT 3.x clients when the SUBACK is sent to the client (as MQTT 3.x clients don't know this property).

        Parameters:
        reasonString - The reason string or null to remove the reason string.
        Throws:
        IllegalArgumentException - If the reason string is not a valid UTF-8 string.
        IllegalArgumentException - If the reason string exceeds the UTF-8 string length limit.
        Since:
        4.3.0, CE 2020.1
      • getUserProperties

        @NotNull ModifiableUserProperties getUserProperties()
        The modifiable UserProperties of the SUBACK packet.

        This setting is only respected for MQTT 5 clients and ignored for MQTT 3.x clients when the SUBACK is sent to the client (as MQTT 3.x clients don't know this property).

        Specified by:
        getUserProperties in interface SubackPacket
        Returns:
        Modifiable user properties.
        Since:
        4.3.0, CE 2020.1