Esempio n. 1
0
 public void removeTorrent(TorrentHash torrentHash) {
   this.announce.removeTorrent(torrentHash);
   SharedTorrent torrent = this.torrents.remove(torrentHash.getHexInfoHash());
   if (torrent != null) {
     torrent.setClientState(ClientState.DONE);
     torrent.close();
   }
 }
Esempio n. 2
0
  /** Close torrent and set final client state before signing off. */
  private void finish() {

    this.announce.stop();

    for (SharedTorrent torrent : this.torrents.values()) {
      torrent.close();
      if (torrent.isFinished()) {
        torrent.setClientState(ClientState.DONE);
      } else {
        torrent.setClientState(ClientState.ERROR);
      }
    }

    logger.info("BitTorrent client signing off.");
  }
Esempio n. 3
0
  public void addTorrent(SharedTorrent torrent) throws IOException, InterruptedException {
    torrent.init();
    if (!torrent.isInitialized()) {
      torrent.close();
      return;
    }

    this.torrents.put(torrent.getHexInfoHash(), torrent);

    // Initial completion test
    if (torrent.isComplete()) {
      torrent.setClientState(ClientState.SEEDING);
    } else {
      torrent.setClientState(ClientState.SHARING);
    }

    this.announce.addTorrent(torrent, this);
  }