本文整理汇总了C#中WowPacketParser.Misc.Packet.GetHeader方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.GetHeader方法的具体用法?C# Packet.GetHeader怎么用?C# Packet.GetHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WowPacketParser.Misc.Packet
的用法示例。
在下文中一共展示了Packet.GetHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public static void Parse(Packet packet, bool isMultiple = false)
{
ParsedStatus status;
var opcode = packet.Opcode;
packet.WriteLine(packet.GetHeader(isMultiple));
if (opcode == 0)
return;
Action<Packet> handler;
if (Handlers.TryGetValue(opcode, out handler))
{
if (Settings.DumpFormat == DumpFormatType.SniffDataOnly)
{
var attrs = handler.Method.GetCustomAttributes(typeof (HasSniffDataAttribute), false);
packet.AddSniffData(StoreNameType.Opcode, packet.Opcode, Opcodes.GetOpcodeName(packet.Opcode));
if (attrs.Length == 0)
{
packet.Status = ParsedStatus.NotParsed;
return; // skip parsing "useless" packets when in SniffData-only-mode
}
}
try
{
handler(packet);
if (packet.Position == packet.Length)
status = ParsedStatus.Success;
else
{
var pos = packet.Position;
var len = packet.Length;
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().ToString());
packet.WriteLine(ex.Message);
packet.WriteLine(ex.StackTrace);
status = ParsedStatus.WithErrors;
}
}
else
{
packet.AsHex();
status = ParsedStatus.NotParsed;
}
if (!isMultiple)
{
packet.Status = status;
if (Settings.DumpFormat != DumpFormatType.SniffDataOnly)
{
// added before for this type
var data = status == ParsedStatus.Success ? Opcodes.GetOpcodeName(packet.Opcode) : status.ToString();
packet.AddSniffData(StoreNameType.Opcode, packet.Opcode, data);
}
}
}
示例2: Parse
public static void Parse(Packet packet, bool isMultiple = false)
{
ParsedStatus status;
packet.WriteLine(packet.GetHeader(isMultiple));
if (packet.Opcode == 0)
return;
var opcode = Opcodes.GetOpcode(packet.Opcode, packet.Direction);
var key = new KeyValuePair<ClientVersionBuild, Opcode>(ClientVersion.VersionDefiningBuild, opcode);
Action<Packet> handler;
var hasHandler = VersionHandlers.TryGetValue(key, out handler);
if (!hasHandler)
{
// If no handler was found, try to find a handler that works for any version.
key = new KeyValuePair<ClientVersionBuild, Opcode>(ClientVersionBuild.Zero, opcode);
hasHandler = VersionHandlers.TryGetValue(key, out handler);
}
if (hasHandler && Settings.DumpFormat != DumpFormatType.HexOnly)
{
if (Settings.DumpFormat == DumpFormatType.SniffDataOnly)
{
var attrs = handler.Method.GetCustomAttributes(typeof(HasSniffDataAttribute), false);
packet.AddSniffData(StoreNameType.Opcode, packet.Opcode, Opcodes.GetOpcodeName(packet.Opcode, packet.Direction));
if (attrs.Length == 0)
{
packet.Status = ParsedStatus.NotParsed;
return; // skip parsing "useless" packets when in SniffData-only-mode
}
}
try
{
handler(packet);
if (packet.Position == packet.Length)
status = ParsedStatus.Success;
else
{
var pos = packet.Position;
var len = packet.Length;
packet.WriteLine("Packet not fully read! Current position: {0} Length: {1} Bytes remaining: {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().ToString());
packet.WriteLine(ex.Message);
packet.WriteLine(ex.StackTrace);
status = ParsedStatus.WithErrors;
}
}
else
{
packet.AsHex();
status = opcode == Opcode.NULL_OPCODE ? ParsedStatus.NotParsed : ParsedStatus.NoStructure;
}
if (!isMultiple)
{
packet.Status = status;
if (Settings.DumpFormat != DumpFormatType.SniffDataOnly)
{
// added before for this type
var data = status == ParsedStatus.Success ? Opcodes.GetOpcodeName(packet.Opcode, packet.Direction) : status.ToString();
packet.AddSniffData(StoreNameType.Opcode, packet.Opcode, data);
}
}
}