disconnect method

Future<void> disconnect()

Implementation

Future<void> disconnect() async {
  if (_disconnecting) {
    return;
  }

  _disconnecting = true;

  await _syncPoller.stop();

  try {
    await _httpBridgeSubscription?.cancel();
    _httpBridgeSubscription = null;
    await _httpServer?.close();
    _httpServer = null;
    await _server.stop();
    await _engine.down();

    _peerCache.clear();
    _statusCache.clear();

    for (final client in subclients) {
      client.clear();
    }
  } finally {
    _disconnecting = false;
  }
}