Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 //接收数据线程函数
 private void RecvFromBoard(object obj)
 {
     while (true)
     {
         try
         {
             var revBytes = _udpClient.Receive(ref _ipTargetEp);
             var header   = GetHeaderFromBytes.GetHeader(revBytes);
             PublishHelper.PublishMsg($"udp-recv://{_prefix}", revBytes);
         }
         catch (SocketException e)
         {
             if (SocketError.Interrupted == e.SocketErrorCode)
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 3
0
        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;
            }
        }