close method

Future<void> close()

Implementation

Future<void> close() async {
  if (!_isRunning) {
    return;
  }
  // log.debug('AutoRelay closing...');

  if (_stopController != null && !_stopController!.isClosed) {
    _stopController!.add(null); // Signal background to stop
    await _backgroundCompleter?.future; // Wait for background to complete
    _stopController!.close();
  }

  await relayFinder.stop().catchError((e) {
    // log.error('AutoRelay: Error stopping RelayFinder during close: $e');
  });

  _isRunning = false;
  // log.debug('AutoRelay closed.');
}