Пример #1
0
        public override bool Equals(object obj)
        {
            HaveMessage msg = obj as HaveMessage;

            if (msg == null)
            {
                return(false);
            }

            return(this.pieceIndex == msg.pieceIndex);
        }
 protected override void HandleHaveMessage(PeerId id, HaveMessage message)
 {
     base.HandleHaveMessage(id, message);
     unchoker.ReceivedHave(id, message.PieceIndex);
 }
 public void HaveEncoding()
 {
     var length = new HaveMessage(150).Encode(buffer, offset);
     Assert.Equal("00-00-00-05-04-00-00-00-96", BitConverter.ToString(buffer, offset, length));
 }
Пример #4
0
        protected virtual void HandleHaveMessage(PeerId id, HaveMessage message)
        {
            id.HaveMessagesReceived++;

            // First set the peers bitfield to true for that piece
            id.BitField[message.PieceIndex] = true;

            // Fastcheck to see if a peer is a seeder or not
            id.Peer.IsSeeder = id.BitField.AllTrue;

            // We can do a fast check to see if the peer is interesting or not when we receive a Have Message.
            // If the peer just received a piece we don't have, he's interesting. Otherwise his state is unchanged
            if (!manager.Bitfield[message.PieceIndex])
                SetAmInterestedStatus(id, true);
        }
Пример #5
0
 protected override void HandleHaveMessage(PeerId id, HaveMessage message)
 {
     // Nothing
 }