本文整理汇总了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));
}
}