stop method

Future<PeerEvent?> stop([
  1. bool force = false
])

When abruptly stopped, this method needs to be called to notify 'announce' The method calls 'announce' once with the parameter bit 'stopped'. force is to force off the identity, with a default value of 'false'. If 'true', the method will not call the 'announce' method Send a 'stopped' request and return a 'null' directly.

Implementation

Future<PeerEvent?> stop([bool force = false]) async {
  if (isDisposed) return null;
  stopIntervalAnnounce();
  if (force) {
    events.emit(TrackerStopEvent(this, null));
    await close();
    return null;
  }
  try {
    var re = await announce(EVENT_STOPPED, await _announceOptions);
    re?.eventType = EVENT_STOPPED;
    events.emit(TrackerStopEvent(this, re));
    await close();
    return re;
  } catch (e) {
    return null;
  }
}