connect method

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

Connect to the specific Mqtt Connection.

Implementation

@override
Future<MqttClientConnectionStatus> connect(
    String server, int port, MqttConnectMessage message) async {
  // Save the parameters for auto reconnect.
  this.server = server;
  this.port = port;
  // ignore: unnecessary_this
  this.connectionMessage = message;
  try {
    await internalConnect(server, port, message);
    return connectionStatus;
  } on Exception {
    connectionStatus.state = MqttConnectionState.faulted;
    rethrow;
  }
}