cancel method

Future<void> cancel()

Ends the wait client or awaitApproval is in, which then throws AtEnrollmentCancelledException once this enrollment's pending keys have left keys, as a denial's do. When keys cannot remove them, this throws what it threw, and a later call tries again.

An approval already written to keys stays there. A client call in flight has ended before this returns, having stopped any client it opened, so the atSign can be opened again at once; a call made inside the work that client awaits, such as a key store or connection it was given, does not wait for it. A connection the caller supplied is left open while the wait runs; once client has opened a client on it, that client owns it, as Atsign.open does, so stopping the client stops the connection too. Nothing withdraws the request on the atServer. Tell the atSign's manager to deny it: an approval after cancel creates an enrollment nobody can use, which the manager would then revoke. A second call after one that succeeded does nothing more, waiting as the first did.

Implementation

Future<void> cancel() async {
  try {
    await (_cancelling ??= _cancelOnce());
  } finally {
    await _clientCallsEnded();
  }
}