connect method

  1. @override
Future<MqttConnectionStatus> connect(
  1. String? server,
  2. int? port,
  3. MqttConnectMessage? message
)
override

Connect to the specific Mqtt Connection.

Implementation

@override
Future<MqttConnectionStatus> connect(
  String? server,
  int? port,
  MqttConnectMessage? message,
) async {
  // Save the parameters for auto reconnect.
  this.server = server;
  this.port = port;
  MqttLogger.log(
    'MqttConnectionHandlerBase::connect - server $server, port $port',
  );

  connectionMessage = message;
  try {
    await internalConnect(server, port, message);
    return connectionStatus;
  } on Exception {
    connectionStatus.state = MqttConnectionState.faulted;
    rethrow;
  }
}