open method

  1. @override
Future open(
  1. String? correlationId
)

Opens the component.

  • correlationId (optional) transaction id to trace execution through call chain.

Implementation

@override
Future open(String? correlationId) async {
  if (_opened) {
    return;
  }

  if (_connection == null) {
    _connection = _createConnection();
    _localConnection = true;
  }

  if (_localConnection != null && _localConnection != false) {
    await _connection!.open(correlationId);
  }

  if (!_connection!.isOpen()) {
    throw ConnectionException(
        correlationId, 'CONNECT_FAILED', 'MQTT connection is not opened');
  }

  // Subscribe right away
  if (_autoSubscribe) {
    await subscribe(correlationId);
  }

  _opened = true;
}