本文整理汇总了C#中System.IO.PacketReader.ReadNext方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadNext方法的具体用法?C# PacketReader.ReadNext怎么用?C# PacketReader.ReadNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.PacketReader
的用法示例。
在下文中一共展示了PacketReader.ReadNext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPacketConsumption
public void TestPacketConsumption()
{
// This just tests the packet reader's ability to
// munch through all the packets in the stream, and
// gracefully reach the end without exception.
// Therefore it will return true, and we will keep
// calling into it, until it returns false. At
// which point it's assumed we've reached the end
// of the stream. If not something went wrong.
PacketReader r = new PacketReader(Input, Input);
while(Input.Position < (Input.Length - 1))
{
if (!r.ReadNext())
{
// Have we reached the end, if not
// this is an error.
Assert.IsTrue(Input.Position == (Input.Length - 1));
}
}
}
示例2: TestMessageConsumption
public void TestMessageConsumption()
{
PacketReader r = new PacketReader(Input, Input);
while(true)
{
if (!r.ReadNext())
{
break;
}
}
Type[] expectedMessages = new[] { typeof(EventId), typeof(Copyright), typeof(Notice), typeof(RefreshRate), typeof(Unknown1), typeof(Unknown1), typeof(KeyFrame) };
IMessage[] extractedMessages = r.MessageQueue.ToArray();
for (int i = 0; i < expectedMessages.Length; ++i)
{
Assert.AreEqual(expectedMessages[i], extractedMessages[i].GetType());
}
}
示例3: HandleReadAdHoc
/// <summary>
/// Call this from your IDriver if you have an entire frames worth of data to process. This useful only
/// when processing keyframe data as it disregards any stateful information associated with the live stream.
/// </summary>
/// <param name="keyFrameData">The stream must contain complete data for a keyframe.</param>
public void HandleReadAdHoc(Stream keyFrameData)
{
PacketReader keyFrameReader = new PacketReader(keyFrameData, new DecryptStreamDecorator(keyFrameData, _decryptor));
_decryptor.Reset();
bool keepReading;
do
{
keepReading = keyFrameReader.ReadNext();
while (keyFrameReader.MessageQueue.Count > 0)
{
DispatchMessage(keyFrameReader.MessageQueue.Dequeue(), false);
}
} while (keepReading);
// The live stream may not yet know its own event type because it probably
// hasn't received the EventId message. So we copy the value across from the
// keyframe. This is necessary to know how to deserialise car packets.
UpdateEventType(keyFrameReader.CurrentEventType);
}
示例4: TestMessageConsumption
public void TestMessageConsumption()
{
PacketReader r = new PacketReader(Input, DecryptedInput);
while (true)
{
if (!r.ReadNext())
{
break;
}
}
// This means we have sucesfully navigated our way to the end and understood
// all the packets along the way ... yipee!
Assert.AreEqual( Input.Length, Input.Position );
}