Ejemplo n.º 1
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));
         }
     }
 }
Ejemplo n.º 2
0
        private void SendCurrentSectionRequestToPeer(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)
            {
                if (this.mEndGameRequest == null)
                {
                    this.UpdateRequestWithNextPiece();
                }

                if (this.mEndGameRequest != null)
                {
                    if (peer.BitField.Get(this.mEndGameRequest.PieceId))
                    {
                        mManager.SendPieceRequestToPeer(peer, this.mEndGameRequest.PieceId, this.mEndGameRequest.Begin, this.mEndGameRequest.Length);
                        this.mEndGamePeers.Add(peer);
                        Config.LogDebugMessage("Sent end game request to peer: " + peer.ToString());
                    }
                }
            }
        }