当前位置: 首页>>代码示例>>C#>>正文


C# Packet.GetPosition方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:CarlosX,项目名称:WowPacketParser,代码行数:37,代码来源:AddonHandler.cs

示例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);
            }
        }
开发者ID:Chaplain,项目名称:WowPacketParser,代码行数:63,代码来源:Handler.cs

示例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++;
                }
            }
        }
开发者ID:Supabad,项目名称:WowPacketParser,代码行数:66,代码来源:Handler.cs


注:本文中的WowPacketParser.Misc.Packet.GetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。