closeConnection method

Future<void> closeConnection(
  1. RelayConnectionKey key
)

Closes one connection and forgets it. An entry that lost its transport, to a reset or to a failed connection attempt, is forgotten just the same: leaving it behind keeps its auth state alive and makes it reconnect.

Implementation

Future<void> closeConnection(RelayConnectionKey key) async {
  final connectivity = globalState.relays.remove(key);
  if (connectivity == null) {
    return;
  }
  Logger.log.d(() => "Disconnecting $key...");
  _forgetAuthState(key);
  _endAuthRetriesLeftBehind(key);
  return connectivity.close();
}