예제 #1
0
        /// <summary>
        /// 向运营商发送链路检测包保持连接
        /// </summary>
        /// <param name="smsSocket"></param>
        protected override void Heartbeat(SmsSocket smsSocket)
        {
            var message = new CmppActiveTestMessage
            {
                SequenceId = NextSequenceId()
            };

            var resp = new CmppActiveTestRespMessage(SendAndWait(smsSocket, message));

            Assert.AreEqual(message.SequenceId, resp.SequenceId);

            Thread.Sleep(3 * 60 * 1000); // TODO: 配置
        }
예제 #2
0
        /// <summary>
        /// 向运营商发送链路检测包保持连接
        /// </summary>
        /// <param name="smsSocket"></param>
        protected override void Heartbeat(SmsSocket smsSocket)
        {
            var message = new CmppActiveTestMessage
            {
                SequenceId = NextSequenceId()
            };

            _log.InfoFormat("心跳数据发送");
            var resp = new CmppActiveTestRespMessage(SendAndWait(smsSocket, message));

            _log.InfoFormat(string.Format("心跳数据:message:{0}-resp:{1}", message.SequenceId, resp.SequenceId));
            Assert.AreEqual(message.SequenceId, resp.SequenceId);
            //每过一段时间发送一段心跳检测,实际短信网关的心跳检测间隔要小于60,且会主动关闭连接,所以设置为小于60秒的时间间隔
            //Thread.Sleep(45 * 1000); // TODO: 配置 不行
            Thread.Sleep(20 * 1000); // TODO: 配置 新调整  2018-03-06
        }
예제 #3
0
        /// <summary>
        /// 解析请求报文
        /// </summary>
        /// <param name="buffer"></param>
        /// <returns></returns>
        protected override SmsMessage Handle(byte[] buffer)
        {
            uint commandId = BitHelper.SubUInt32(buffer, CmppMessage.CommandIdIndex);

            switch (commandId)
            {
            case CmppCommandId.CMPP_ACTIVE_TEST:
            {
                var message = new CmppActiveTestMessage(buffer);
                var ack     = new CmppActiveTestRespMessage
                {
                    SequenceId = message.SequenceId
                };
                return(ack);
            }

            default:
                return(null);    // throw new NotImplementedException("UnHandleRequest: " + commandId);
            }
        }