Examples of PeerMessage


Examples of com.turn.ttorrent.common.protocol.PeerMessage

          }

          buffer.rewind();

          try {
            PeerMessage message = PeerMessage.parse(buffer, torrent);
            logger.trace("Received {} from {}", message, peer);

            // Wait if needed to reach configured download rate.
            this.rateLimit(
              PeerExchange.this.torrent.getMaxDownloadRate(),
View Full Code Here

Examples of com.turn.ttorrent.common.protocol.PeerMessage

        // Loop until told to stop. When stop was requested, loop until
        // the queue is served.
        while (!stop || (stop && sendQueue.size() > 0)) {
          try {
            // Wait for two minutes for a message to send
            PeerMessage message = sendQueue.poll(
                PeerExchange.KEEP_ALIVE_IDLE_MINUTES,
                TimeUnit.MINUTES);

            if (message == null) {
              if (stop) {
                return;
              }

              message = PeerMessage.KeepAliveMessage.craft();
            }

            logger.trace("Sending {} to {}", message, peer);

            ByteBuffer data = message.getData();
            long size = 0;
            while (!stop && data.hasRemaining()) {
                int written = channel.write(data);
                size += written;
              if (written < 0) {
View Full Code Here

Examples of com.turn.ttorrent.common.protocol.PeerMessage

            this.torrent.getCompletedPieces().cardinality(),
            this.torrent.getPieceCount()
          });

        // Send a HAVE message to all connected peers
        PeerMessage have = PeerMessage.HaveMessage.craft(piece.getIndex());
        for (SharingPeer remote : this.connected.values()) {
          remote.send(have);
        }

        // Force notify after each piece is completed to propagate download
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.