stopDiscovery method

  1. @override
Future<void> stopDiscovery()
override

Stops any in-progress inquiry.

Implementation

@override
Future<void> stopDiscovery() async {
  discoveryStopped = true;
  stopDiscoveryCount++;
  // Mirror every real backend (and the interface doc): stopDiscovery aborts
  // live inquiries, closing their streams. A fake that leaves them open
  // models a platform that exists nowhere and hides facade coordination
  // bugs (e.g. _activeDiscoveries stuck > 0 pausing the scan forever).
  for (final c in _liveDiscoveries.toList()) {
    if (!c.isClosed) unawaited(c.close());
  }
  _liveDiscoveries.clear();
}