Beispiel #1
0
 // Read msg to input stream
 public override bool FromBytes(MBinaryReader mbr)
 {
     // Skip msg_id and msg_len as it has been read by outside.
     data.FromBytes(mbr);
     if (msg_id != MSG_ID)
     {
         Console.WriteLine("Invalid msg id when parse msg type [CG_Echo_Request], expect:[17250], real:[" + msg_id + "]");
         return(false);
     }
     if (msg_len != MSG_LEN)
     {
         Console.WriteLine("Invalid msg len when parse msg type [CG_Echo_Request], expect:[274], real:[" + msg_len + "]");
         return(false);
     }
     return(true);
 }
Beispiel #2
0
 // Read msg to input stream
 public override bool FromBytes(MBinaryReader mbr)
 {
     // Skip msg_id and msg_len as it has been read by outside.
     data.FromBytes(mbr);
     response_code = (EResponseCode)mbr.ReadInt16();
     if (msg_id != MSG_ID)
     {
         Console.WriteLine("Invalid msg id when parse msg type [GC_Echo_Response], expect:[16542], real:[" + msg_id + "]");
         return(false);
     }
     if (msg_len != MSG_LEN)
     {
         Console.WriteLine("Invalid msg len when parse msg type [GC_Echo_Response], expect:[276], real:[" + msg_len + "]");
         return(false);
     }
     return(true);
 }
Beispiel #3
0
        // Verify msg type: EchoMsg
        private static void Verify_EchoMsg()
        {
            EchoMsg stSrc = new EchoMsg();

            // Make object rand
            stSrc.protocol_version = "test";
            stSrc.int_param        = 76;
            stSrc.char_array       = "test";
            byte[]        src_bytes = stSrc.ToBytes();
            MBinaryReader mbr       = new MBinaryReader(src_bytes);
            EchoMsg       stDst     = new EchoMsg();

            stDst.FromBytes(mbr);
            // Verify object content
            if (stSrc.int_param != stDst.int_param)
            {
                Console.WriteLine("Failed to verify field: int_param");
            }
            if (stSrc.enum_value != stDst.enum_value)
            {
                Console.WriteLine("Failed to verify field: enum_value");
            }
            // Compare object by bytes
            byte[] dst_bytes = stDst.ToBytes();
            if (dst_bytes.Length != src_bytes.Length)
            {
                Console.WriteLine("Failed to verify field: EchoMsg by bytes length");
            }
            for (int byte_index = 0; byte_index < dst_bytes.Length; ++byte_index)
            {
                if (src_bytes[byte_index] != dst_bytes[byte_index])
                {
                    Console.WriteLine("Failed to verify field: EchoMsg by bytes length");
                }
            }
        }