getConnectMessage method

  1. @protected
MqttConnectMessage getConnectMessage (
  1. String username,
  2. String password
)
@protected

Gets a pre-configured connect message if one has not been supplied by the user. Returns an MqttConnectMessage that can be used to connect to a message broker.

Implementation

@protected
MqttConnectMessage getConnectMessage(String username, String password) =>
    connectionMessage ??= MqttConnectMessage()
        .withClientIdentifier(clientIdentifier)
        // Explicitly set the will flag
        .withWillQos(MqttQos.atMostOnce)
        .keepAliveFor(MqttClientConstants.defaultKeepAlive)
        .authenticateAs(username, password)
        .startClean();