Class ConnectPacket.ConnectPacketBuilder
- java.lang.Object
-
- software.amazon.awssdk.crt.mqtt5.packets.ConnectPacket.ConnectPacketBuilder
-
- Enclosing class:
- ConnectPacket
public static final class ConnectPacket.ConnectPacketBuilder extends Object
A class to that allows for the creation of a ConnectPacket. Set all of the settings you want in the packet and then use the build() function to get a ConnectPacket populated with the settings defined in the builder.
-
-
Constructor Summary
Constructors Constructor Description ConnectPacketBuilder()
Creates a new ConnectPacketBuilder so a ConnectPacket can be created.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectPacket
build()
Creates a new ConnectPacket using the settings set in the builder.ConnectPacket.ConnectPacketBuilder
withClientId(String clientId)
Sets the unique string identifying the client to the server.ConnectPacket.ConnectPacketBuilder
withKeepAliveIntervalSeconds(Long keepAliveInteralSeconds)
Sets the maximum time interval, in seconds, that is permitted to elapse between the point at which the client finishes transmitting one MQTT packet and the point it starts sending the next.ConnectPacket.ConnectPacketBuilder
withMaximumPacketSizeBytes(Long maximumPacketSizeBytes)
Sets the maximum packet size the client is willing to handle.ConnectPacket.ConnectPacketBuilder
withPassword(byte[] password)
Sets the opaque binary data that the server may use for client authentication and authorization.ConnectPacket.ConnectPacketBuilder
withReceiveMaximum(Long receiveMaximum)
Sets the maximum number of in-flight QoS 1 and 2 messages the client is willing to handle.ConnectPacket.ConnectPacketBuilder
withRequestProblemInformation(Boolean requestProblemInformation)
Sets whether requests that the server send additional diagnostic information (via response string or user properties) in DisconnectPacket or ConnAckPacket from the server.ConnectPacket.ConnectPacketBuilder
withRequestResponseInformation(Boolean requestResponseInformation)
Sets whether requests that the server send response information in the subsequent ConnAckPacket.ConnectPacket.ConnectPacketBuilder
withSessionExpiryIntervalSeconds(Long sessionExpiryIntervalSeconds)
Sets the time interval, in seconds, that the client requests the server to persist this connection's MQTT session state for.ConnectPacket.ConnectPacketBuilder
withUsername(String username)
Sets the string value that the server may use for client authentication and authorization.ConnectPacket.ConnectPacketBuilder
withUserProperties(List<UserProperty> userProperties)
Sets the list of MQTT5 user properties included with the packet.ConnectPacket.ConnectPacketBuilder
withWill(PublishPacket will)
Sets the definition of a message to be published when the connection's session is destroyed by the server or when the will delay interval has elapsed, whichever comes first.ConnectPacket.ConnectPacketBuilder
withWillDelayIntervalSeconds(Long willDelayIntervalSeconds)
Sets the time interval, in seconds, that the server should wait (for a session reconnection) before sending the will message associated with the connection's session.
-
-
-
Method Detail
-
withKeepAliveIntervalSeconds
public ConnectPacket.ConnectPacketBuilder withKeepAliveIntervalSeconds(Long keepAliveInteralSeconds)
Sets the maximum time interval, in seconds, that is permitted to elapse between the point at which the client finishes transmitting one MQTT packet and the point it starts sending the next. The client will use PINGREQ packets to maintain this property. If the responding ConnAckPacket contains a keep alive property value, then that is the negotiated keep alive value. Otherwise, the keep alive sent by the client is the negotiated value. See MQTT5 Keep Alive NOTE: The keepAliveIntervalSeconds HAS to be larger than the pingTimeoutMs time set in the Mqtt5ClientOptions.- Parameters:
keepAliveInteralSeconds
- the maximum time interval, in seconds, that is permitted to elapse between the point at which the client finishes transmitting one MQTT packet and the point it starts sending the next.- Returns:
- The ConnectPacketBuilder after setting the keep alive interval.
-
withClientId
public ConnectPacket.ConnectPacketBuilder withClientId(String clientId)
Sets the unique string identifying the client to the server. Used to restore session state between connections. If left empty, the broker will auto-assign a unique client id. When reconnecting, the Mqtt5Client will always use the auto-assigned client id. See MQTT5 Client Identifier- Parameters:
clientId
- A unique string identifying the client to the server.- Returns:
- The ConnectPacketBuilder after setting the client ID.
-
withUsername
public ConnectPacket.ConnectPacketBuilder withUsername(String username)
Sets the string value that the server may use for client authentication and authorization. See MQTT5 User Name- Parameters:
username
- The string value that the server may use for client authentication and authorization.- Returns:
- The ConnectPacketBuilder after setting the username.
-
withPassword
public ConnectPacket.ConnectPacketBuilder withPassword(byte[] password)
Sets the opaque binary data that the server may use for client authentication and authorization. See MQTT5 Password- Parameters:
password
- Opaque binary data that the server may use for client authentication and authorization.- Returns:
- The ConnectPacketBuilder after setting the password.
-
withSessionExpiryIntervalSeconds
public ConnectPacket.ConnectPacketBuilder withSessionExpiryIntervalSeconds(Long sessionExpiryIntervalSeconds)
Sets the time interval, in seconds, that the client requests the server to persist this connection's MQTT session state for. Has no meaning if the client has not been configured to rejoin sessions. Must be non-zero in order to successfully rejoin a session. If the responding ConnAckPacket contains a session expiry property value, then that is the negotiated session expiry value. Otherwise, the session expiry sent by the client is the negotiated value. See MQTT5 Session Expiry Interval- Parameters:
sessionExpiryIntervalSeconds
- A time interval, in seconds, that the client requests the server to persist this connection's MQTT session state for.- Returns:
- The ConnectPacketBuilder after setting the session expiry interval.
-
withRequestResponseInformation
public ConnectPacket.ConnectPacketBuilder withRequestResponseInformation(Boolean requestResponseInformation)
Sets whether requests that the server send response information in the subsequent ConnAckPacket. This response information may be used to set up request-response implementations over MQTT, but doing so is outside the scope of the MQTT5 spec and client. See MQTT5 Request Response Information- Parameters:
requestResponseInformation
- If true, requests that the server send response information in the subsequent ConnAckPacket.- Returns:
- The ConnectPacketBuilder after setting the request response information.
-
withRequestProblemInformation
public ConnectPacket.ConnectPacketBuilder withRequestProblemInformation(Boolean requestProblemInformation)
Sets whether requests that the server send additional diagnostic information (via response string or user properties) in DisconnectPacket or ConnAckPacket from the server. See MQTT5 Request Problem Information- Parameters:
requestProblemInformation
- If true, requests that the server send additional diagnostic information (via response string or user properties) in DisconnectPacket or ConnAckPacket from the server.- Returns:
- The ConnectPacketBuilder after setting the request problem information.
-
withReceiveMaximum
public ConnectPacket.ConnectPacketBuilder withReceiveMaximum(Long receiveMaximum)
Sets the maximum number of in-flight QoS 1 and 2 messages the client is willing to handle. If omitted or null, then no limit is requested. See MQTT5 Receive Maximum- Parameters:
receiveMaximum
- The maximum number of in-flight QoS 1 and 2 messages the client is willing to handle.- Returns:
- The ConnectPacketBuilder after setting the receive maximum.
-
withMaximumPacketSizeBytes
public ConnectPacket.ConnectPacketBuilder withMaximumPacketSizeBytes(Long maximumPacketSizeBytes)
Sets the maximum packet size the client is willing to handle. If omitted or null, then no limit beyond the natural limits of MQTT packet size is requested. See MQTT5 Maximum Packet Size- Parameters:
maximumPacketSizeBytes
- The maximum packet size the client is willing to handle- Returns:
- The ConnectPacketBuilder after setting the maximum packet size.
-
withWillDelayIntervalSeconds
public ConnectPacket.ConnectPacketBuilder withWillDelayIntervalSeconds(Long willDelayIntervalSeconds)
Sets the time interval, in seconds, that the server should wait (for a session reconnection) before sending the will message associated with the connection's session. If omitted or null, the server will send the will when the associated session is destroyed. If the session is destroyed before a will delay interval has elapsed, then the will must be sent at the time of session destruction. See MQTT5 Will Delay Interval- Parameters:
willDelayIntervalSeconds
- A time interval, in seconds, that the server should wait (for a session reconnection) before sending the will message associated with the connection's session.- Returns:
- The ConnectPacketBuilder after setting the will message delay interval.
-
withWill
public ConnectPacket.ConnectPacketBuilder withWill(PublishPacket will)
Sets the definition of a message to be published when the connection's session is destroyed by the server or when the will delay interval has elapsed, whichever comes first. If null, then nothing will be sent. See MQTT5 Will- Parameters:
will
- The message to be published when the connection's session is destroyed by the server or when the will delay interval has elapsed, whichever comes first.- Returns:
- The ConnectPacketBuilder after setting the will message.
-
withUserProperties
public ConnectPacket.ConnectPacketBuilder withUserProperties(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 ConnectPacketBuilder after setting the user properties.
-
build
public ConnectPacket build()
Creates a new ConnectPacket using the settings set in the builder.- Returns:
- The ConnectPacket created from the builder
-
-