Beispiel #1
0
  @Override
  public void handleEvent(TorrentEvent event) {
    if (event == TorrentEvent.STOPPED) {
      if (!finished.get()) {
        cancel();
      } else {
        remove();
      }
    } else if (event == TorrentEvent.STATUS_CHANGED) {
      // considered to be finished uploading if seed ratio has been
      // reached
      boolean finished = torrent.isFinished();
      float seedRatio = torrent.getSeedRatio();
      TorrentStatus status = torrent.getStatus();
      int seedTime = status != null ? status.getSeedingTime() : 0;

      float targetSeedRatio = torrentManager.getTorrentManagerSettings().getSeedRatioLimit();
      int targetSeedTime = torrentManager.getTorrentManagerSettings().getSeedTimeLimit();

      if (finished && (seedRatio >= targetSeedRatio || seedTime >= targetSeedTime)) {
        this.finished.set(true);
        torrent.stop();
      }
    }
  }
Beispiel #2
0
 @Override
 public float getSeedRatio() {
   return torrent.getSeedRatio();
 }