コード例 #1
0
        public void RejectRequests()
        {
            List <RequestMessage> messages = new List <RequestMessage>();

            peer.IsChoking = false;
            peer.BitField.SetAll(true);

            RequestMessage m;

            while ((m = picker.PickPiece(peer, peers)) != null)
            {
                messages.Add(m);
            }

            foreach (RequestMessage message in messages)
            {
                picker.CancelRequest(peer, message.PieceIndex, message.StartOffset, message.RequestLength);
            }

            List <RequestMessage> messages2 = new List <RequestMessage>();

            while ((m = picker.PickPiece(peer, peers)) != null)
            {
                messages2.Add(m);
            }

            Assert.AreEqual(messages.Count, messages2.Count, "#1");
            for (int i = 0; i < messages.Count; i++)
            {
                Assert.IsTrue(messages2.Contains(messages[i]), "#2." + i);
            }
        }
コード例 #2
0
 public virtual void CancelRequest(PeerId peer, int piece, int startOffset, int length)
 {
     CheckOverriden();
     picker.CancelRequest(peer, piece, startOffset, length);
 }