示例#1
0
        // Verify msg type: ChatMsg
        private static void Verify_ChatMsg()
        {
            ChatMsg stSrc = new ChatMsg();

            // Make object rand
            stSrc.content    = "test";
            stSrc.speaker_id = 78;
            stSrc.time       = 51;
            byte[]        src_bytes = stSrc.ToBytes();
            MBinaryReader mbr       = new MBinaryReader(src_bytes);
            ChatMsg       stDst     = new ChatMsg();

            stDst.FromBytes(mbr);
            // Verify object content
            if (stSrc.speaker_id != stDst.speaker_id)
            {
                Console.WriteLine("Failed to verify field: speaker_id");
            }
            if (stSrc.time != stDst.time)
            {
                Console.WriteLine("Failed to verify field: time");
            }
            // Compare object by bytes
            byte[] dst_bytes = stDst.ToBytes();
            if (dst_bytes.Length != src_bytes.Length)
            {
                Console.WriteLine("Failed to verify field: ChatMsg 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: ChatMsg by bytes length");
                }
            }
        }
示例#2
0
 // Constructor
 public GC_Chat_Msg()
 {
     msg_len = MSG_LEN;
     msg_id  = MSG_ID;
     data    = new ChatMsg();
 }
示例#3
0
 // Constructor
 public CG_Chat_Cmd()
 {
     msg_len = MSG_LEN;
     msg_id  = MSG_ID;
     data    = new ChatMsg();
 }