本文整理汇总了C#中Network.ReadMagic方法的典型用法代码示例。如果您正苦于以下问题:C# Network.ReadMagic方法的具体用法?C# Network.ReadMagic怎么用?C# Network.ReadMagic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network.ReadMagic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadNext
public static Message ReadNext(Stream stream, Network network, ProtocolVersion version, CancellationToken cancellationToken, byte[] buffer, out PerformanceCounter counter)
{
BitcoinStream bitStream = new BitcoinStream(stream, false)
{
ProtocolVersion = version,
ReadCancellationToken = cancellationToken
};
if(!network.ReadMagic(stream, cancellationToken, true))
throw new FormatException("Magic incorrect, the message comes from another network");
Message message = new Message();
message._Buffer = buffer;
using(message.SkipMagicScope(true))
{
message.Magic = network.Magic;
message.ReadWrite(bitStream);
}
counter = bitStream.Counter;
return message;
}
示例2: ReadNext
public static Message ReadNext(Socket socket, Network network, ProtocolVersion version, CancellationToken cancellationToken)
{
var stream = new NetworkStream(socket, false);
BitcoinStream bitStream = new BitcoinStream(stream, false)
{
ProtocolVersion = version,
ReadCancellationToken = cancellationToken
};
network.ReadMagic(stream, cancellationToken);
Message message = new Message();
using(message.SkipMagicScope(true))
{
message.Magic = network.Magic;
NodeServerTrace.Trace.TraceEvent(TraceEventType.Verbose, 0, "Message recieved");
message.ReadWrite(bitStream);
}
return message;
}