コード例 #1
0
 public void peer_PieceSectionFinished(bool isActive, Peer peer, int pieceId, int begin, int length)
 {
     if (isActive)
     {
         mManager.SendPieceRequestToPeer(peer, pieceId, begin + length,
                                         DownloadStrategyHelp.CalculatePieceSectionLength(mManager, pieceId, begin + length));
     }
 }
コード例 #2
0
        private void UpdateRequestWithNextPiece()
        {
            // else get a new piece to find
            int pieceId = DownloadStrategyHelp.DecideNextPiece(mManager, null);

            if (pieceId >= 0)
            {
                int pieceSectionLength = DownloadStrategyHelp.CalculatePieceSectionLength(mManager, pieceId, 0);
                this.mEndGameRequest = new PieceRequest(null, pieceId, 0, pieceSectionLength);
            }
        }
コード例 #3
0
 private void StartDownloadingNextPieceIfPossible(Peer peer)
 {
     // if the peer isn't choking, isn't currently downloading anything and the maximum number of downloads hasn't been reached
     // we can authorise a request to be sent
     if (!peer.HeIsChoking && peer.AmIInterested && !this.mManager.IsPeerDownloading(peer))                // && this.piecesDownloading.Count < Config.ActiveConfig.SimultaneousDownloadsLimit)
     {
         int pieceId = DownloadStrategyHelp.DecideNextPiece(mManager, peer);
         if (pieceId >= 0)
         {
             mManager.SendPieceRequestToPeer(peer, pieceId, 0, DownloadStrategyHelp.CalculatePieceSectionLength(mManager, pieceId, 0));
         }
     }
 }
コード例 #4
0
 private void UpdateEndGameRequest()
 {
     if (this.mEndGameRequest == null)
     {
         UpdateRequestWithNextPiece();
     }
     else
     {
         // continue the old piece if it hasnt finished
         int pieceLength = DownloadStrategyHelp.CalculatePieceSectionLength(mManager, this.mEndGameRequest.PieceId, this.mEndGameRequest.Begin + this.mEndGameRequest.Length);
         if (pieceLength <= 0)
         {
             UpdateRequestWithNextPiece();
         }
         else
         {
             this.mEndGameRequest.Begin += this.mEndGameRequest.Length;
             this.mEndGameRequest.Length = pieceLength;
         }
     }
 }