本文整理匯總了C#中MonoTorrent.Client.PeerId.TryProcessAsyncReads方法的典型用法代碼示例。如果您正苦於以下問題:C# PeerId.TryProcessAsyncReads方法的具體用法?C# PeerId.TryProcessAsyncReads怎麽用?C# PeerId.TryProcessAsyncReads使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MonoTorrent.Client.PeerId
的用法示例。
在下文中一共展示了PeerId.TryProcessAsyncReads方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: HandleRequestMessage
protected virtual void HandleRequestMessage(PeerId id, RequestMessage message)
{
// If we are not on the last piece and the user requested a stupidly big/small amount of data
// we will close the connection
if (manager.Torrent.Pieces.Count != (message.PieceIndex + 1))
if (message.RequestLength > RequestMessage.MaxSize || message.RequestLength < RequestMessage.MinSize)
throw new MessageException("Illegal piece request received. Peer requested " + message.RequestLength.ToString() + " byte");
PieceMessage m = new PieceMessage(message.PieceIndex, message.StartOffset, message.RequestLength);
// If we're not choking the peer, enqueue the message right away
if (!id.AmChoking)
{
id.IsRequestingPiecesCount++;
id.PieceReads.Add(m);
id.TryProcessAsyncReads();
}
// If the peer supports fast peer and the requested piece is one of the allowed pieces, enqueue it
// otherwise send back a reject request message
else if (id.SupportsFastPeer && ClientEngine.SupportsFastPeer)
{
if (id.AmAllowedFastPieces.Contains(message.PieceIndex))
{
id.IsRequestingPiecesCount++;
id.PieceReads.Add(m);
id.TryProcessAsyncReads();
}
else
id.Enqueue(new RejectRequestMessage(m));
}
}