Example #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="agent">The <see cref="ISipAgent" /> that owns this transaction.</param>
 /// <param name="id">The globally unique transaction ID.</param>
 /// <param name="transport">The <see cref="ISipTransport" /> to be used for this transaction.</param>
 /// <remarks>
 /// The timers <see cref="TimerA" /> through <see cref="TimerK" /> are initialized
 /// with the correct <see cref="PolledTimer.Interval" /> values for the given transport.
 /// These timers will then need to be <see cref="PolledTimer.Reset()" /> before they
 /// are actually used so they will be scheduled to fire at the correct time.
 /// </remarks>
 protected SipTransaction(ISipAgent agent, string id, ISipTransport transport)
 {
     this.agent      = agent;
     this.id         = id;
     this.state      = SipTransactionState.Unknown;
     this.transport  = transport;
     this.baseTimers = transport.Settings.BaseTimers;
     this.agentState = null;
 }
Example #2
0
        /// <summary>
        /// Sets a new transaction state.
        /// </summary>
        /// <param name="newState">The new state.</param>
        private void SetState(SipTransactionState newState)
        {
            SipTransactionState oldState;

            if (newState == base.State)
            {
                return;
            }

            oldState   = base.State;
            base.State = newState;

            switch (newState)
            {
            case SipTransactionState.InviteCalling:

                break;

            case SipTransactionState.InviteProceeding:

                break;

            case SipTransactionState.InviteCompleted:

                base.TimerG.Interval = base.BaseTimers.T1;
                base.TimerH.Interval = Helper.Multiply(base.BaseTimers.T1, 64);
                break;

            case SipTransactionState.InviteConfirmed:

                base.TimerI.Interval = isUdp ? base.BaseTimers.T4 : TimeSpan.Zero;
                break;

            case SipTransactionState.Trying:

                break;

            case SipTransactionState.Proceeding:

                break;

            case SipTransactionState.Completed:

                base.TimerJ.Interval = isUdp ? Helper.Multiply(base.BaseTimers.T1, 64) : TimeSpan.Zero;
                break;

            case SipTransactionState.Terminated:

                break;
            }
        }
Example #3
0
        /// <summary>
        /// Sets a new transaction state.
        /// </summary>
        /// <param name="newState">The new state.</param>
        private void SetState(SipTransactionState newState)
        {
            SipTransactionState oldState;

            if (newState == base.State)
            {
                return;
            }

            oldState   = base.State;
            base.State = newState;

            switch (newState)
            {
            case SipTransactionState.InviteCalling:

                if (isUdp)
                {
                    base.TimerA.Interval = base.BaseTimers.T1;
                }

                base.TimerB.Interval = Helper.Multiply(base.BaseTimers.T1, 64);
                break;

            case SipTransactionState.InviteProceeding:

                break;

            case SipTransactionState.InviteCompleted:

                if (isUdp)
                {
                    base.TimerD.Interval = Helper.Min(Helper.Multiply(base.BaseTimers.T1, 64), TimeSpan.FromSeconds(32));
                }
                else
                {
                    base.TimerD.Interval = TimeSpan.Zero;
                }

                break;

            case SipTransactionState.Trying:

                base.TimerF.Interval = Helper.Multiply(base.BaseTimers.T1, 64);

                if (isUdp)
                {
                    base.TimerE.Interval = base.BaseTimers.T1;
                }

                break;

            case SipTransactionState.Proceeding:

                break;

            case SipTransactionState.Completed:

                if (isUdp)
                {
                    base.TimerK.Interval = base.BaseTimers.T4;
                }
                else
                {
                    base.State = SipTransactionState.Terminated;
                }

                break;

            case SipTransactionState.Terminated:

                break;
            }
        }