private Enqueue ( |
||
msg | ||
Результат | void |
public virtual void Unchoke(PeerId peerToUnchoke) { peerToUnchoke.AmChoking = false; peerToUnchoke.TorrentManager.UploadingTo++; peerToUnchoke.Enqueue(new UnchokeMessage()); peerToUnchoke.LastUnchoked = DateTime.Now; }
private void RequestNextNeededPiece(PeerId id) { var index = _bitField.FirstFalse(); if (index == -1) return; //throw exception or switch to regular? var m = new LTMetadata(id, LTMetadata.eMessageType.Request, index); id.Enqueue(m); _requestTimeout = DateTime.Now.Add(Timeout); }
public virtual void Choke(PeerId id) { id.AmChoking = true; id.TorrentManager.UploadingTo--; id.Enqueue(new ChokeMessage()); }
/// <summary> /// Checks the send queue of the peer to see if there are any outstanding pieces which they requested /// and rejects them as necessary /// </summary> /// <param name="peer"></param> private void RejectPendingRequests(PeerId peer) { var length = peer.QueueLength; for (var i = 0; i < length; i++) { var message = peer.Dequeue(); if (!(message is PieceMessage)) { peer.Enqueue(message); continue; } var pieceMessage = (PieceMessage) message; // If the peer doesn't support fast peer, then we will never requeue the message if (!(peer.SupportsFastPeer && ClientEngine.SupportsFastPeer)) { peer.IsRequestingPiecesCount--; continue; } // If the peer supports fast peer, queue the message if it is an AllowedFast piece // Otherwise send a reject message for the piece if (peer.AmAllowedFastPieces.Contains(pieceMessage.PieceIndex)) peer.Enqueue(pieceMessage); else { peer.IsRequestingPiecesCount--; peer.Enqueue(new RejectRequestMessage(pieceMessage)); } } }