本文整理汇总了C#中WowPacketParser.Misc.Packet.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.GetPosition方法的具体用法?C# Packet.GetPosition怎么用?C# Packet.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WowPacketParser.Misc.Packet
的用法示例。
在下文中一共展示了Packet.GetPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadClientAddonsList
public static void ReadClientAddonsList(ref Packet packet)
{
var decompCount = packet.ReadInt32();
packet = packet.Inflate(decompCount);
if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_8_9464))
{
var count = packet.ReadInt32("Addons Count");
_addonCount = count;
for (var i = 0; i < count; i++)
{
packet.ReadCString("Name", i);
packet.ReadBoolean("Enabled", i);
packet.ReadInt32("CRC", i);
packet.ReadInt32("Unk Int32", i);
}
packet.ReadTime("Time");
}
else
{
int count = 0;
while (packet.GetPosition() != packet.GetLength())
{
packet.ReadCString("Name");
packet.ReadBoolean("Enabled");
packet.ReadInt32("CRC");
packet.ReadInt32("Unk Int32");
count++;
}
_addonCount = count;
}
}
示例2: Parse
public static void Parse(Packet packet, bool headerOnly = false, bool isMultiple = false)
{
ParsedStatus status;
var opcode = packet.Opcode;
packet.WriteLine("{0}: {1} (0x{2}) Length: {3} Time: {4} Number: {5}{6}",
packet.Direction, Opcodes.GetOpcodeName(opcode), opcode.ToString("X4"),
packet.GetLength(), packet.Time.ToString("MM/dd/yyyy HH:mm:ss.fff"),
packet.Number, isMultiple ? " (part of another packet)" : String.Empty);
if (opcode == 0)
return;
if (headerOnly)
status = ParsedStatus.Success;
else
{
Action<Packet> handler;
if (Handlers.TryGetValue(opcode, out handler))
{
try
{
handler(packet);
if (packet.GetPosition() == packet.GetLength())
status = ParsedStatus.Success;
else
{
var pos = packet.GetPosition();
var len = packet.GetLength();
packet.WriteLine("Packet not fully read! Current position is {0}, length is {1}, and diff is {2}.",
pos, len, len - pos);
if (len < 300) // If the packet isn't "too big" and it is not full read, print its hex table
packet.AsHex();
status = ParsedStatus.WithErrors;
}
}
catch (Exception ex)
{
packet.WriteLine(ex.GetType());
packet.WriteLine(ex.Message);
packet.WriteLine(ex.StackTrace);
status = ParsedStatus.WithErrors;
}
}
else
{
packet.AsHex();
status = ParsedStatus.NotParsed;
}
}
if (isMultiple == false)
{
packet.Status = status;
var data = status == ParsedStatus.Success ? Opcodes.GetOpcodeName(packet.Opcode) : status.ToString();
packet.AddSniffData(StoreNameType.Opcode, packet.Opcode, data);
}
}
示例3: Parse
public static void Parse(Packet packet, bool headerOnly = false)
{
var opcode = packet.Opcode;
packet.Writer.WriteLine("{0}: {1} (0x{2}) Length: {3} Time: {4} Number: {5}",
packet.Direction, Opcodes.GetOpcodeName(opcode), opcode.ToString("X4"),
packet.GetLength(), packet.Time.ToString("MM/dd/yyyy HH:mm:ss.fff"), packet.Number);
if (headerOnly)
{
lock (Handlers)
{
Statistics.PacketsSuccessfullyParsed++;
}
return;
}
Action<Packet> handler;
if (Handlers.TryGetValue(opcode, out handler))
{
try
{
handler(packet);
if (packet.GetPosition() == packet.GetLength())
lock (Handlers)
{
Statistics.PacketsSuccessfullyParsed++;
}
else
{
var pos = packet.GetPosition();
var len = packet.GetLength();
packet.Writer.WriteLine("Packet not fully read! Current position is {0}, length is {1}, and diff is {2}.",
pos, len, len - pos);
if (len < 300) // If the packet isn't "too big" and it is not full read, print its hex table
packet.Writer.WriteLine(packet.AsHex());
lock (Handlers)
{
Statistics.PacketsParsedWithErrors++;
}
}
}
catch (Exception ex)
{
packet.Writer.WriteLine(ex.GetType());
packet.Writer.WriteLine(ex.Message);
packet.Writer.WriteLine(ex.StackTrace);
lock (Handlers)
{
Statistics.PacketsParsedWithErrors++;
}
}
}
else
{
packet.Writer.WriteLine(packet.AsHex());
lock (Handlers)
{
Statistics.PacketsNotParsed++;
}
}
}