public void TestBytesToStruct() { //此处构造一个登陆响应报文,是从真实的数据中抓出来的 byte[] rsp = { 00, 03, 00, 00, 03, 0x22, 00, 04, 0x0a, 00, 01, 0xc0, 00, 01, 0xf0, 0xe4 }; GtsMsgHeader header = GetHeaderFromBytes.GetHeader(rsp); Assert.AreEqual(802, header.u16Opcode); MsgGtsa2GtsmLogonRsp rspObj = new MsgGtsa2GtsmLogonRsp(); int used = rspObj.DeserializeToStruct(rsp, 0); Assert.AreEqual(header.u16Opcode, rspObj.header.u16Opcode); Assert.AreEqual(used, rspObj.Len); used = rspObj.DeserializeToStruct(rsp, 10); Assert.AreEqual(-1, used); }
private void OnLinkMsgFromBoard(SubscribeMsg msg) { byte[] msgBytes = msg.Data; GtsMsgHeader header = GetHeaderFromBytes.GetHeader(msgBytes); string ip = GetIpFromTopic(msg.Topic); switch (header.u16Opcode) { case GtsMsgType.O_GTSAGTSM_LOGON_RSP: DealConnectRsp(ip); break; case GtsMsgType.O_GTSAGTSM_TRACE_CTRL_RSP: //发送开关的响应 DealSendTraceSwitchRsp(ip, msg.Data); break; case GtsMsgType.O_GTSAGTSM_FDL_RSP: break; case GtsMsgType.O_GTSAGTSM_FDL_COMPLETE_IND: break; case GtsMsgType.O_GTSAGTSM_FILTER_RULE_RSP: break; case GtsMsgType.O_GTSAGTSM_FILTER_RESET_RSP: break; case GtsMsgType.O_GTSAGTSM_TRACE_MSG: //抄送的消息 DealTraceMsg(msg.Data); break; default: break; } }