Пример #1
0
        void PacketFormat(out ServerRule[] serverRules, byte[] receivePacketBytes)
        {
            using (MemoryStream stream = new MemoryStream(receivePacketBytes))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    reader.ReadBytes(11);

                    int ruleCount = reader.ReadInt16();
                    serverRules = new ServerRule[ruleCount];//jvxf2m1

                    for (int i = 0; i < ruleCount; i++)
                    {
                        int    ruleNameLength = reader.ReadByte();
                        byte[] ruleName       = reader.ReadBytes(ruleNameLength);

                        int    ruleValueLength = reader.ReadByte();
                        byte[] ruleValue       = reader.ReadBytes(ruleValueLength);

                        serverRules[i] = new ServerRule(Encoding.Default.GetString(ruleName), Encoding.Default.GetString(ruleValue));
                    }
                }
            }
        }
Пример #2
0
        void PacketFormat(out ServerRule[] serverRules, byte[] receivePacketBytes)
        {
            using (MemoryStream stream = new MemoryStream(receivePacketBytes))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    reader.ReadBytes(11);

                    int ruleCount = reader.ReadInt16();
                    serverRules = new ServerRule[ruleCount];//jvxf2m1

                    for (int i = 0; i < ruleCount; i++)
                    {
                        int ruleNameLength = reader.ReadByte();
                        byte[] ruleName = reader.ReadBytes(ruleNameLength);

                        int ruleValueLength = reader.ReadByte();
                        byte[] ruleValue = reader.ReadBytes(ruleValueLength);

                        serverRules[i] = new ServerRule(Encoding.Default.GetString(ruleName), Encoding.Default.GetString(ruleValue));
                    }
                }
            }
        }