protected override void HandleTtsOffsetStartFrame(SaiTtsFrameOffsetStart startFrame)
        {
            // 收到OffsetStart,停止握手超时计时器。
            LogUtility.Info(string.Format("{0}: 收到的OffsetStart报文. 停止Tres_start计时器。",
                                          this.Context.RsspEP.ID));
            this.Context.StopHandshakeTimer();

            // 发送OffsetAnswer1
            var seqNo = (ushort)this.Context.SeqNoManager.GetAndUpdateSendSeq();

            var offsetAnswer1 = new SaiTtsFrameOffsetAnswer1(seqNo,
                                                             TripleTimestamp.CurrentTimestamp,
                                                             this.TTS.RemoteLastSendTimestamp,
                                                             this.TTS.LocalLastRecvTimeStamp, 0);

            this.Context.NextLayer.SendUserData(offsetAnswer1.GetBytes());
            LogUtility.Info(string.Format("{0}: 发送OffsetAnswer1.", this.Context.RsspEP.ID));

            // 更新时间戳
            this.Calculator.ResTimestamp2 = offsetAnswer1.SenderTimestamp;

            // 启动Tres_start计时器,等待OffsetAnswer2报文。
            LogUtility.Info(string.Format("{0}: 启动Tres_start计时器,等待OffsetAnswer2报文。", this.Context.RsspEP.ID));
            this.Context.StartHandshakeTimer();

            // 更新状态。
            this.Context.CurrentState = new TtsWaitingforAnswer2State(this);
        }
Beispiel #2
0
        public void Test1()
        {
            var frameInital = new SaiTtsFrameOffsetAnswer1();

            frameInital.SequenceNo                = 100;
            frameInital.SenderTimestamp           = 1000;
            frameInital.SenderLastRecvTimestamp   = 900;
            frameInital.ReceiverLastSendTimestamp = 800;
            frameInital.ResponseCycle             = 3000;

            var bytes = frameInital.GetBytes();

            var actual = SaiFrame.Parse(bytes) as SaiTtsFrameOffsetAnswer1;

            Assert.AreEqual(frameInital.FrameType, actual.FrameType);
            Assert.AreEqual(frameInital.SequenceNo, actual.SequenceNo);
            Assert.AreEqual(frameInital.SenderTimestamp, actual.SenderTimestamp);
            Assert.AreEqual(frameInital.SenderLastRecvTimestamp, actual.SenderLastRecvTimestamp);
            Assert.AreEqual(frameInital.ReceiverLastSendTimestamp, actual.ReceiverLastSendTimestamp);
            Assert.AreEqual(frameInital.ResponseCycle, actual.ResponseCycle);
        }