Package com.torrent4j.model

Examples of com.torrent4j.model.Torrent


            .get("frame-decoder")).setHandshaked(true);
        ((PeerWireMessageDecoder) e.getChannel().getPipeline()
            .get("message-decoder")).setHandshaked(true);

        final Hash hash = new Hash(HashType.SHA1, message.torrentHash);
        final Torrent torrent = controller.findTorrent(hash);

        if (torrent == null) {
          e.getChannel().disconnect();
          return;
        }

        TorrentPeer peer = torrent.getSwarm().findPeer(
            (InetSocketAddress) e.getChannel().getRemoteAddress(),
            message.peerID);
        if (peer == null) {
          peer = new TorrentPeer(torrent);
          peer.setAddress((InetSocketAddress) e.getChannel()
View Full Code Here


  public static void main(String[] args) throws IOException, InterruptedException {
    final TorrentController controller = new TorrentController(
        new PeerWireProtocol(), new InMemoryTorrentStorage());
    controller.start(1234);
   
    final Torrent torrent = Torrent.load(Paths.get("test.torrent"));
    System.out.println("Torrent hash is " + torrent.getHash().getString());

    // controller.checkExistingData(torrent);

    controller.registerTorrent(torrent);
    final TorrentPeer peer = new TorrentPeer(torrent);
    peer.setAddress(new InetSocketAddress(Inet4Address
        .getByName("127.0.0.1"), 34096));
    torrent.getSwarm().addPeer(peer);
   
    while(true) {
      Thread.sleep(1000);
      System.out.println((peer.getTrafficControl().getCurrentDownloadSpeed() / 1024) + " kb/s");
      //peer.getTrafficControl().setDownloadSpeedLimit(32 * 1024);
      torrent.getTrafficControl().setDownloadSpeedLimit(256 * 1024);
    }

    // System.out.println(((StandardTorrentStrategy)
    // torrent.getStrategy()).getPieceSelector()
    // .selectPiece(peer));
View Full Code Here

TOP

Related Classes of com.torrent4j.model.Torrent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.