Пример #1
0
        /// <summary>
        /// 处理时钟偏移修正响应信息
        /// </summary>
        /// <param name="offsetRsp">响应报文</param>
        /// <param name="currentTimestamp">收到响应报文时的时间戳</param>
        private void HandleResponseFrame(SaiTtsFrame offsetRsp, UInt32 currentTimestamp)
        {
            try
            {
                long minOffset = (long)offsetRsp.ReceiverLastSendTimestamp - (long)offsetRsp.SenderLastRecvTimestamp;
                long maxOffset = (long)currentTimestamp - (long)offsetRsp.SenderTimestamp;

                // Notify observer
                _observer.OnTimeOffsetUpdated(minOffset, maxOffset);
            }
            catch (System.Exception ex)
            {
                LogUtility.Error(ex.ToString());
            }
        }
Пример #2
0
        protected override void HandleTtsFrame(SaiTtsFrame ttsFrame)
        {
            if (ttsFrame.FrameType == SaiFrameType.TTS_OffsetStart)
            {
                this.Context.RsspEP.DefenseTech = MessageDelayDefenseTech.TTS;

                var strategy = new TtsDefenseStrategy(this.Context.FrameTransport, false);
                this.Context.DefenseStrategy = strategy;

                this.Context.CurrentState = new TtsWaitingforStartState(this.Context, strategy);
                this.Context.CurrentState.HandleFrame(ttsFrame);
            }
            else
            {
                throw new Exception("SaiInvalideState状态时,收到的第一条帧不是OffsetStart。");
            }
        }
Пример #3
0
        protected override void HandleTtsFrame(SaiTtsFrame ttsFrame)
        {
            // 更新TTS
            this.TTS.UpdateRemoteLastSendTimestamp(ttsFrame.SenderTimestamp);
            this.TTS.UpdateLocalLastRecvTimeStamp(TripleTimestamp.CurrentTimestamp);

            // 分类消息。
            if (ttsFrame.FrameType == SaiFrameType.TTS_OffsetStart)
            {
                this.HandleTtsOffsetStartFrame(ttsFrame as SaiTtsFrameOffsetStart);
            }
            else if (ttsFrame.FrameType == SaiFrameType.TTS_OffsetAnswer1)
            {
                this.HandleTtsOffsetAnswer1Frame(ttsFrame as SaiTtsFrameOffsetAnswer1);
            }
            else if (ttsFrame.FrameType == SaiFrameType.TTS_OffsetAnswer2)
            {
                this.HandleTtsOffsetAnswer2Frame(ttsFrame as SaiTtsFrameOffsetAnswer2);
            }
            else if (ttsFrame.FrameType == SaiFrameType.TTS_OffsetEstimate)
            {
                this.HandleTtsEstimateFrame(ttsFrame as SaiTtsFrameEstimate);
            }
            else if (ttsFrame.FrameType == SaiFrameType.TTS_OffsetEnd)
            {
                this.HandleTtsOffsetEndFrame(ttsFrame as SaiTtsFrameOffsetEnd);
            }
            else if (ttsFrame.FrameType == SaiFrameType.TTS_AppData)
            {
                this.HandleTtsAppFrame(ttsFrame as SaiTtsFrameAppData);
            }
            else
            {
                throw new Exception(string.Format("{0}: {1} 中收到非Tts帧。",
                                                  this.Context.RsspEP.ID, this.GetType().Name));
            }
        }
Пример #4
0
 protected virtual long CalcTtsTimeDelay(SaiTtsFrame ttsFrame)
 {
     return(0);
 }
Пример #5
0
 protected virtual void HandleTtsFrame(SaiTtsFrame ttsFrame)
 {
     LogUtility.Error(string.Format("{0}: {1}.{2} not implement!",
                                    this.Context.RsspEP.ID, this.GetType().Name,
                                    new StackFrame(0).GetMethod().Name.Split('.').Last()));
 }
Пример #6
0
 protected override long CalcTtsTimeDelay(SaiTtsFrame ttsFrame)
 {
     return(this.Calculator.CalcTimeDelay(TripleTimestamp.CurrentTimestamp, ttsFrame.SenderTimestamp));
 }