// Verify msg type: GC_Echo_Response private static void Verify_GC_Echo_Response() { GC_Echo_Response stSrc = new GC_Echo_Response(); // Make object rand byte[] src_bytes = stSrc.ToBytes(); MBinaryReader mbr = new MBinaryReader(src_bytes); GC_Echo_Response stDst = new GC_Echo_Response(); stDst.msg_len = mbr.ReadUInt16(); stDst.msg_id = mbr.ReadUInt16(); stDst.FromBytes(mbr); // Verify object content if (stDst.msg_len != GC_Echo_Response.MSG_LEN) { Console.WriteLine("Failed to verify field: msg_len"); } if (stDst.msg_id != GC_Echo_Response.MSG_ID) { Console.WriteLine("Failed to verify field: msg_id"); } if (stSrc.response_code != stDst.response_code) { Console.WriteLine("Failed to verify field: response_code"); } // Compare object by bytes byte[] dst_bytes = stDst.ToBytes(); if (dst_bytes.Length != src_bytes.Length) { Console.WriteLine("Failed to verify field: GC_Echo_Response 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: GC_Echo_Response by bytes length"); } } }
public static Message CreateMessageById(AUINT16 nMsgId) { Message msg = null; switch (nMsgId) { case CG_HeartBeat_Msg.MSG_ID: msg = new CG_HeartBeat_Msg(); break; case GC_HeartBeat_Msg.MSG_ID: msg = new GC_HeartBeat_Msg(); break; case CG_Echo_Request.MSG_ID: msg = new CG_Echo_Request(); break; case GC_Echo_Response.MSG_ID: msg = new GC_Echo_Response(); break; case CG_Chat_Cmd.MSG_ID: msg = new CG_Chat_Cmd(); break; case GC_Chat_Msg.MSG_ID: msg = new GC_Chat_Msg(); break; default: Console.WriteLine("Invalid msg id:" + nMsgId); break; } return(msg); }
// Default handle of msg: GC_Echo_Response protected virtual bool OnGC_Echo_Response(GC_Echo_Response msg) { CSLogger.LogDebug("ServerMsgHandler: Recv msg: [" + msg.ToString() + "]"); return(false); }