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


C# PacketReader.ReadUInt64方法代码示例

本文整理汇总了C#中System.IO.PacketReader.ReadUInt64方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadUInt64方法的具体用法?C# PacketReader.ReadUInt64怎么用?C# PacketReader.ReadUInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.PacketReader的用法示例。


在下文中一共展示了PacketReader.ReadUInt64方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandlePacket

        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            PacketReader reader = new PacketReader(data);

            reader.ReadUInt64(); // Skip 8 bytes
            if(reader.ReadUInt32() != 0x10)
            {
                Logger.WriteWarning("[WRN] Packet 0x3 0x34's first value was not 0x10! Investigate.");
            }

            uint partOfLobby = reader.ReadUInt32();
            PSOLocation destination;
            if(partOfLobby == 0) // Gate area
            {
                destination = new PSOLocation(0f, 1f, 0f, 0f, -0.22f, 2.4f, 198.75f);
            }
            else // Shop area
            {
                destination = new PSOLocation(0f, 1f, 0f, 20f, 0.20f, 1.23f, -175.25f);
            }
            Map lobbyMap = ZoneManager.Instance.MapFromInstance("lobby", "lobby");
            lobbyMap.SpawnClient(context, destination, "lobby");
        }
开发者ID:ChowZenki,项目名称:PolarisServer,代码行数:23,代码来源:ReturnToLobbyHandler.cs

示例2: Handshake

        private void Handshake(ushort packet_opcode, PacketReader packet_data, bool packet_encrypted)
        {
            if (packet_encrypted)
            {
                throw (new Exception("[SecurityAPI::Handshake] Received an illogical (encrypted) handshake packet."));
            }
            if (m_client_security)
            {
                // If this object does not need a handshake
                if (m_security_flags.handshake == 0)
                {
                    // Client should only accept it then
                    if (packet_opcode == 0x9000)
                    {
                        if (m_accepted_handshake)
                        {
                            throw (new Exception("[SecurityAPI::Handshake] Received an illogical handshake packet (duplicate 0x9000)."));
                        }
                        m_accepted_handshake = true; // Otherwise, all good here
                        return;
                    }
                    // Client should not send any 0x5000s!
                    else if (packet_opcode == 0x5000)
                    {
                        throw (new Exception("[SecurityAPI::Handshake] Received an illogical handshake packet (0x5000 with no handshake)."));
                    }
                    // Programmer made a mistake in calling this function
                    else
                    {
                        throw (new Exception("[SecurityAPI::Handshake] Received an illogical handshake packet (programmer error)."));
                    }
                }
                else
                {
                    // Client accepts the handshake
                    if (packet_opcode == 0x9000)
                    {
                        // Can't accept it before it's started!
                        if (!m_started_handshake)
                        {
                            throw (new Exception("[SecurityAPI::Handshake] Received an illogical handshake packet (out of order 0x9000)."));
                        }
                        if (m_accepted_handshake) // Client error
                        {
                            throw (new Exception("[SecurityAPI::Handshake] Received an illogical handshake packet (duplicate 0x9000)."));
                        }
                        // Otherwise, all good here
                        m_accepted_handshake = true;
                        return;
                    }
                    // Client sends a handshake response
                    else if (packet_opcode == 0x5000)
                    {
                        if (m_started_handshake) // Client error
                        {
                            throw (new Exception("[SecurityAPI::Handshake] Received an illogical handshake packet (duplicate 0x5000)."));
                        }
                        m_started_handshake = true;
                    }
                    // Programmer made a mistake in calling this function
                    else
                    {
                        throw (new Exception("[SecurityAPI::Handshake] Received an illogical handshake packet (programmer error)."));
                    }
                }

                ulong key_array = 0;
                byte[] tmp_bytes;

                m_value_B = packet_data.ReadUInt32();
                m_client_key = packet_data.ReadUInt64();

                m_value_K = G_pow_X_mod_P(m_value_p, m_value_x, m_value_B);

                key_array = MAKELONGLONG_(m_value_A, m_value_B);
                KeyTransformValue(ref key_array, m_value_K, (byte)(LOBYTE_(LOWORD_(m_value_K)) & 0x03));
                m_blowfish.Initialize(BitConverter.GetBytes(key_array));

                tmp_bytes = m_blowfish.Decode(BitConverter.GetBytes(m_client_key));
                m_client_key = BitConverter.ToUInt64(tmp_bytes, 0);

                key_array = MAKELONGLONG_(m_value_B, m_value_A);
                KeyTransformValue(ref key_array, m_value_K, (byte)(LOBYTE_(LOWORD_(m_value_B)) & 0x07));
                if (m_client_key != key_array)
                {
                    throw (new Exception("[SecurityAPI::Handshake] Client signature error."));
                }

                key_array = MAKELONGLONG_(m_value_A, m_value_B);
                KeyTransformValue(ref key_array, m_value_K, (byte)(LOBYTE_(LOWORD_(m_value_K)) & 0x03));
                m_blowfish.Initialize(BitConverter.GetBytes(key_array));

                m_challenge_key = MAKELONGLONG_(m_value_A, m_value_B);
                KeyTransformValue(ref m_challenge_key, m_value_K, (byte)(LOBYTE_(LOWORD_(m_value_A)) & 0x07));
                tmp_bytes = m_blowfish.Encode(BitConverter.GetBytes(m_challenge_key));
                m_challenge_key = BitConverter.ToUInt64(tmp_bytes, 0);

                KeyTransformValue(ref m_handshake_blowfish_key, m_value_K, 0x3);
                m_blowfish.Initialize(BitConverter.GetBytes(m_handshake_blowfish_key));

//.........这里部分代码省略.........
开发者ID:GoneUp,项目名称:ModuleFilter,代码行数:101,代码来源:SecurityManager.cs

示例3: HandlePacket

        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            var reader = new PacketReader(data, position, size);
            var clientTime = reader.ReadUInt64();

            var writer = new PacketWriter();
            writer.Write(clientTime);
            writer.Write(Helper.Timestamp(DateTime.UtcNow));
            context.SendPacket(0x11, 0xE, 0, writer.ToArray());
        }
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:10,代码来源:SimplePackets.cs


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