Ejemplo n.º 1
0
        // Write msg to output stream
        public byte[] ToBytes()
        {
            MBinaryWriter mbw = new MBinaryWriter();

            mbw.WriteString(protocol_version, protocol_version_size);
            mbw.Write(int_param);
            for (Int32 nElementIndex = 0; nElementIndex < int_array_size; ++nElementIndex)
            {
                mbw.Write(int_array[nElementIndex]);
            }
            mbw.WriteString(char_array, char_array_size);
            byte[] rand_string_field_bytes = rand_string_field.ToBytes();
            mbw.Write(rand_string_field_bytes);
            for (Int32 nElementIndex = 0; nElementIndex < rand_string_array_size; ++nElementIndex)
            {
                byte[] rand_string_array_bytes = rand_string_array[nElementIndex].ToBytes();
                mbw.Write(rand_string_array_bytes);
            }
            mbw.Write((Int16)enum_value);
            byte[] EchoMsg_bytes = mbw.ToArray();
            mbw.Close();
            mbw = null;
            // Verify the length of msg
            if (EchoMsg_bytes.Length != 270)
            {
                Console.WriteLine("Invalid msg len, expect:270, real:EchoMsg_bytes.Length");
                return(null);
            }
            return(EchoMsg_bytes);
        }
Ejemplo n.º 2
0
        // Write msg to output stream
        public byte[] ToBytes()
        {
            MBinaryWriter mbw = new MBinaryWriter();

            mbw.WriteString(data, data_size);
            byte[] RandString_bytes = mbw.ToArray();
            mbw.Close();
            mbw = null;
            // Verify the length of msg
            if (RandString_bytes.Length != 32)
            {
                Console.WriteLine("Invalid msg len, expect:32, real:RandString_bytes.Length");
                return(null);
            }
            return(RandString_bytes);
        }
Ejemplo n.º 3
0
        // Write msg to output stream
        public byte[] ToBytes()
        {
            MBinaryWriter mbw = new MBinaryWriter();

            mbw.WriteString(key, key_size);
            mbw.WriteString(value, value_size);
            byte[] KeyValuePair_bytes = mbw.ToArray();
            mbw.Close();
            mbw = null;
            // Verify the length of msg
            if (KeyValuePair_bytes.Length != 482)
            {
                Console.WriteLine("Invalid msg len, expect:482, real:KeyValuePair_bytes.Length");
                return(null);
            }
            return(KeyValuePair_bytes);
        }
Ejemplo n.º 4
0
        // Write msg to output stream
        public override byte[] ToBytes()
        {
            MBinaryWriter mbw = new MBinaryWriter();

            mbw.Write(msg_len);
            mbw.Write(msg_id);
            mbw.Write(heartbeat_index);
            byte[] CG_HeartBeat_Msg_bytes = mbw.ToArray();
            mbw.Close();
            mbw = null;
            // Verify the length of msg
            if (CG_HeartBeat_Msg_bytes.Length != 6)
            {
                Console.WriteLine("Invalid msg len, expect:6, real:CG_HeartBeat_Msg_bytes.Length");
                return(null);
            }
            return(CG_HeartBeat_Msg_bytes);
        }
Ejemplo n.º 5
0
        // Write msg to output stream
        public byte[] ToBytes()
        {
            MBinaryWriter mbw = new MBinaryWriter();

            mbw.WriteString(content, content_size);
            mbw.Write(speaker_id);
            mbw.Write(time);
            byte[] ChatMsg_bytes = mbw.ToArray();
            mbw.Close();
            mbw = null;
            // Verify the length of msg
            if (ChatMsg_bytes.Length != 264)
            {
                Console.WriteLine("Invalid msg len, expect:264, real:ChatMsg_bytes.Length");
                return(null);
            }
            return(ChatMsg_bytes);
        }
Ejemplo n.º 6
0
        // Write msg to output stream
        public override byte[] ToBytes()
        {
            MBinaryWriter mbw = new MBinaryWriter();

            mbw.Write(msg_len);
            mbw.Write(msg_id);
            byte[] data_bytes = data.ToBytes();
            mbw.Write(data_bytes);
            byte[] GC_Chat_Msg_bytes = mbw.ToArray();
            mbw.Close();
            mbw = null;
            // Verify the length of msg
            if (GC_Chat_Msg_bytes.Length != 268)
            {
                Console.WriteLine("Invalid msg len, expect:268, real:GC_Chat_Msg_bytes.Length");
                return(null);
            }
            return(GC_Chat_Msg_bytes);
        }
Ejemplo n.º 7
0
        // Write msg to output stream
        public override byte[] ToBytes()
        {
            MBinaryWriter mbw = new MBinaryWriter();

            mbw.Write(msg_len);
            mbw.Write(msg_id);
            byte[] data_bytes = data.ToBytes();
            mbw.Write(data_bytes);
            byte[] CG_Echo_Request_bytes = mbw.ToArray();
            mbw.Close();
            mbw = null;
            // Verify the length of msg
            if (CG_Echo_Request_bytes.Length != 274)
            {
                Console.WriteLine("Invalid msg len, expect:274, real:CG_Echo_Request_bytes.Length");
                return(null);
            }
            return(CG_Echo_Request_bytes);
        }
Ejemplo n.º 8
0
        // Write msg to output stream
        public override byte[] ToBytes()
        {
            MBinaryWriter mbw = new MBinaryWriter();

            mbw.Write(msg_len);
            mbw.Write(msg_id);
            byte[] data_bytes = data.ToBytes();
            mbw.Write(data_bytes);
            mbw.Write((Int16)response_code);
            byte[] GC_Echo_Response_bytes = mbw.ToArray();
            mbw.Close();
            mbw = null;
            // Verify the length of msg
            if (GC_Echo_Response_bytes.Length != 276)
            {
                Console.WriteLine("Invalid msg len, expect:276, real:GC_Echo_Response_bytes.Length");
                return(null);
            }
            return(GC_Echo_Response_bytes);
        }