예제 #1
0
        public void When_1000_transactions_are_in_trying_state()
        {
            var m = new Mock<ISipMessageSender>();
            var l = new Mock<ISipListener>();
            var txTable = new SipClientTransactionTable();

            SipNonInviteClientTransaction ctx;
            for(int i=0;i <1000;i++)
            {
                /*provide a separate sequence so that each transaction has a unique ID*/
                var r = new SipRequestBuilder().WithCSeq(new SipCSeqHeaderBuilder().WithSequence(i).Build()).Build();
                ctx = new SipNonInviteClientTransaction(txTable, m.Object, l.Object, r, new TimerFactory());
                ctx.SendRequest(); /*go to state*/
            }

            Assert.IsTrue(txTable.Keys.Count == 1000);

            /*extra race condition check. Wait T1 time, so while disposing the transactions, their Retransmit is firing.*/
            var dateTime = DateTime.Now.AddMilliseconds(SipConstants.T1);
            while (dateTime > DateTime.Now) { };

            txTable.Values.ToList().ForEach(a => a.Dispose());

            Assert.IsTrue(txTable.Keys.Count == 0);
        }
예제 #2
0
        internal override StateResult HandleResponse(SipNonInviteClientTransaction ctx, SipResponse response)
        {
            var statusCode = response.StatusLine.StatusCode;

            if (statusCode >= 100 && statusCode < 200)
            {
                ctx.ChangeState(SipNonInviteClientTransaction.ProceedingState);
            }
            else if (statusCode >= 200 && statusCode < 700)
            {
                ctx.ChangeState(SipNonInviteClientTransaction.CompletedState);
            }

            return new StateResult() { InformToUser = true };
        }
예제 #3
0
        public void Test_Retransmit()
        {
            var s = new Mock<ISipMessageSender>();
            var l = new Mock<ISipListener>();
            var txTable = new SipClientTransactionTable();
            var request = new SipRequestBuilder().Build();
            SipNonInviteClientTransaction ctx = new SipNonInviteClientTransaction(txTable, s.Object, l.Object, request, new TimerFactoryMockBuilder().Build());
            ctx.SendRequest();

            var dateTime = DateTime.Now.AddMilliseconds(SipConstants.T1);
            while (dateTime > DateTime.Now) {};

            s.Verify(ss => ss.SendRequest(request), Times.Exactly(2));

            ctx.Dispose();
        }
예제 #4
0
        internal override StateResult HandleResponse(SipNonInviteClientTransaction ctx, SipResponse response)
        {
            var statusCode = response.StatusLine.StatusCode;

            if (statusCode >= 100 && statusCode < 200)
            {
                ctx.ChangeState(SipNonInviteClientTransaction.ProceedingState);
            }
            else if (statusCode >= 200 && statusCode < 700)
            {
                ctx.ChangeState(SipNonInviteClientTransaction.CompletedState);
            }

            return(new StateResult()
            {
                InformToUser = true
            });
        }
예제 #5
0
 internal abstract StateResult HandleResponse(SipNonInviteClientTransaction ctx, SipResponse response);
예제 #6
0
 protected override void Given()
 {
     _ctx = new SipNonInviteClientTransaction(TxTable, Sender.Object, Listener.Object, Request, TimerFactory);
     GivenOverride();
 }
예제 #7
0
        internal override void Retransmit(SipNonInviteClientTransaction ctx)
        {
            ctx.ReTransmitTimer.Interval = SipConstants.T2;

            ctx.SendRequestInternal();
        }
예제 #8
0
 internal override void Initialize(SipNonInviteClientTransaction transaction)
 {
 }
예제 #9
0
 internal override void Initialize(SipNonInviteClientTransaction transaction)
 {
     //start the timers
     transaction.ReTransmitTimer.Start();
     transaction.TimeOutTimer.Start();
 }
예제 #10
0
        internal override void Retransmit(SipNonInviteClientTransaction ctx)
        {
            ctx.ReTransmitTimer.Interval = SipConstants.T2;

            ctx.SendRequestInternal();
        }
예제 #11
0
        public ISipClientTransaction CreateClientTransaction(SipRequest request)
        {
            Check.Require(request, "request");
            Check.IsTrue(SipMethods.IsMethod(request.RequestLine.Method), "Request method is not supported");

            ISipClientTransaction tx;

            if (request.RequestLine.Method == SipMethods.Ack)
            {
                throw new ArgumentException("Can not create a transaction for the 'ACK' request");
            }

            ISipListener txListener = _sipListener;

            SipAbstractDialog dialog;
            if (_dialogTable.TryGetValue(GetDialogId(request, true), out dialog))
            {
                txListener = dialog;
            }

            if(request.RequestLine.Method == SipMethods.Invite)
            {
                tx = new SipInviteClientTransaction(
                    ClientTransactionTable,
                    this,
                    txListener,
                    request,
                    _stack.GetTimerFactory(),
                    _stack.CreateHeaderFactory(),
                    _stack.CreateMessageFactory());
            }
            else
            {
                tx = new SipNonInviteClientTransaction(
                    ClientTransactionTable,
                    this,
                    txListener,
                    request,
                    _stack.GetTimerFactory());
            }

            return tx;
        }
예제 #12
0
 internal override void Initialize(SipNonInviteClientTransaction transaction)
 {
     //start the timers
     transaction.ReTransmitTimer.Start();
     transaction.TimeOutTimer.Start();
 }
예제 #13
0
 internal abstract StateResult HandleResponse(SipNonInviteClientTransaction ctx, SipResponse response);
예제 #14
0
 internal abstract void Retransmit(SipNonInviteClientTransaction transaction);
예제 #15
0
 internal abstract void Initialize(SipNonInviteClientTransaction transaction);
예제 #16
0
 internal abstract void Initialize(SipNonInviteClientTransaction transaction);
예제 #17
0
 internal abstract void Retransmit(SipNonInviteClientTransaction transaction);
예제 #18
0
 internal override void Initialize(SipNonInviteClientTransaction transaction)
 {
 }