Interface ModifiableConnackPacket
-
- All Superinterfaces:
ConnackPacket
public interface ModifiableConnackPacket extends ConnackPacket
AConnackPacketthat can be modified before it is sent to the client.- Since:
- 4.2.0, CE 2020.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull ModifiableUserPropertiesgetUserProperties()Get the modifiableUserPropertiesof the CONNACK packet.voidsetAssignedClientIdentifier(@Nullable String assignedClientIdentifier)Set the assigned client identifier that is sent in the CONNACK packet.voidsetReasonCode(@NotNull ConnackReasonCode reasonCode)Set aConnackReasonCodeto the CONNACK packet.voidsetReasonString(@Nullable String reasonString)Set the reason string.voidsetResponseInformation(@Nullable String responseInformation)Set the response information.voidsetServerReference(@Nullable String serverReference)Set the server reference.voidsetSessionPresent(boolean sessionPresent)Sets the session present flag in the CONNACK packet HiveMQ sends to the client.-
Methods inherited from interface com.hivemq.extension.sdk.api.packets.connack.ConnackPacket
getAssignedClientIdentifier, getAuthenticationData, getAuthenticationMethod, getMaximumPacketSize, getMaximumQoS, getReasonCode, getReasonString, getReceiveMaximum, getResponseInformation, getRetainAvailable, getServerKeepAlive, getServerReference, getSessionExpiryInterval, getSessionPresent, getSharedSubscriptionsAvailable, getSubscriptionIdentifiersAvailable, getTopicAliasMaximum, getWildCardSubscriptionAvailable
-
-
-
-
Method Detail
-
setReasonCode
void setReasonCode(@NotNull ConnackReasonCode reasonCode)
Set aConnackReasonCodeto the CONNACK packet.Switching from successful to unsuccessful and vice versa is not supported.
- Parameters:
reasonCode- The reason code to set.- Throws:
NullPointerException- If reason code isnull.IllegalStateException- If switching from successful reason code to unsuccessful reason code or vice versa. Check outConnackReasonCodeto see what reason code counts as a success or unsuccessful code.- Since:
- 4.2.0, CE 2020.1
- See Also:
How reason codes are translated from MQTT 5 to MQTT 3.
-
setReasonString
void setReasonString(@Nullable String reasonString)
Set the reason string.A reason must not be set for a successful connack.
This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.
- Parameters:
reasonString- The reason string to set.- Throws:
IllegalStateException- If reason code isConnackReasonCode.SUCCESS.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.2.0, CE 2020.1
-
getUserProperties
@NotNull ModifiableUserProperties getUserProperties()
Get the modifiableUserPropertiesof the CONNACK packet.- Specified by:
getUserPropertiesin interfaceConnackPacket- Returns:
- Modifiable user properties.
- Since:
- 4.2.0, CE 2020.1
-
setResponseInformation
void setResponseInformation(@Nullable String responseInformation)
Set the response information.This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.
- Parameters:
responseInformation- The new response information for the CONNACK.- Throws:
IllegalArgumentException- If the response information is not a valid UTF-8 string.IllegalArgumentException- If the response information exceeds the UTF-8 string length limit.IllegalStateException- If the response information was not requested in the connect packet.- Since:
- 4.2.0, CE 2020.1
-
setServerReference
void setServerReference(@Nullable String serverReference)
Set the server reference.This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.
- Parameters:
serverReference- The new server reference for the CONNACK.- Throws:
IllegalArgumentException- If the server reference is not a valid UTF-8 string.IllegalArgumentException- If the server reference exceeds the UTF-8 string length limit.- Since:
- 4.2.0, CE 2020.1
-
setAssignedClientIdentifier
void setAssignedClientIdentifier(@Nullable String assignedClientIdentifier)
Set the assigned client identifier that is sent in the CONNACK packet.This does not change the client identifier for HiveMQ, only the content of the CONNACK packet that is sent to the client is changed.
If you want to change the client identifier used by HiveMQ use a
ConnectInboundInterceptorinstead.Set this value to
nullto prevent a assigned identifier from being sent to the client in the CONNACK packet.This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.
- Parameters:
assignedClientIdentifier- The assigned client identifier sent in the CONNACK.- Throws:
IllegalArgumentException- If the client identifier is not a valid UTF-8 string.IllegalArgumentException- If the client identifier exceeds the UTF-8 string length limit.IllegalArgumentException- If the client identifier is empty. Usenullto prevent sending the assigned identifier- Since:
- 4.6.0, CE 2021.1
-
setSessionPresent
void setSessionPresent(boolean sessionPresent)
Sets the session present flag in the CONNACK packet HiveMQ sends to the client.This flag only impacts the content of the CONNACK packet, the flag does not change overall HiveMQ client session behavior.
CAUTION: Clients typically clear their previous state when they receive a CONNACK packet with sessionPresent = false. Setting this flag to false can impact pending QoS 2 message flows.
- Parameters:
sessionPresent- The session present flag sent in the CONNACK.- Since:
- 4.28.0, CE 2024.4
-
-