示例#1
0
        public static NetworkObject UnPack(byte[] byte_0)
        {
            int           num4;
            NetworkObject class2 = new NetworkObject();

            for (int i = 0; (i + 7) < byte_0.Length; i = num4 + 1)
            {
                byte[] buffer;
                int    num2   = ((int)BitConverter.ToUInt32(byte_0, i)) & 0x7fffffff;
                bool   flag   = (BitConverter.ToUInt32(byte_0, i) & 0x80000000) > 0;
                int    length = Math.Abs(BitConverter.ToInt32(byte_0, i + 4));
                num4 = (i + 7) + length;
                if (num4 > (byte_0.Length - 1))
                {
                    num4 = byte_0.Length - 1;
                }
                if (flag)
                {
                    buffer = new byte[length];
                    Array.Copy(byte_0, i + 8, buffer, 0, length);
                    class2.AddField(num2, new NetworkObjectField(UnPack(buffer)));
                }
                else
                {
                    buffer = new byte[length];
                    Array.Copy(byte_0, i + 8, buffer, 0, length);
                    class2.AddField(num2, new NetworkObjectField(buffer));
                }
            }
            return(class2);
        }
示例#2
0
        /// <summary>
        /// Enqueue <see cref="NetworkObject"/> to be sent to the client.
        /// </summary>
        public void EnqueueMessage(ObjectOpcode opcode, NetworkObject message)
        {
            var packet = new NetworkObject();

            packet.AddField(0, NetworkObjectField.CreateIntField((int)opcode));
            packet.AddField(1, NetworkObjectField.CreateObjectField(message));
            EnqueueMessage(packet);
        }
示例#3
0
        public override NetworkObject ToNetworkObject()
        {
            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream))
                {
                    this.Write(writer);

                    NetworkObject class2 = new NetworkObject();
                    class2.AddField(0, NetworkObjectField.CreateByteArrayField(stream.ToArray()));
                    return(class2);
                }
            }
        }