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(); } }
/** 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."); }
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); }