Пример #1
0
        internal SoftPhone(ISipProvider provider, SipMessageFactory messageFactory, SipHeaderFactory headerFactory,
            SipAddressFactory addressFactory, ISoftPhoneStateProvider stateProvider, ITimerFactory timerFactory, SipListeningPoint listeningPoint)
        {
            ListeningPoint = listeningPoint;
            _provider = provider;
            _messageFactory = messageFactory;
            _headerFactory = headerFactory;
            _addressFactory = addressFactory;
            _stateProvider = stateProvider;
            _timerFactory = timerFactory;

            InternalState = _stateProvider.GetIdle();
            InternalState.Initialize(this);
            RetransmitRingingTimer = _timerFactory.CreateRingingTimer(OnRetransmitRinging);
            EndWaitForAckTimer = _timerFactory.CreateInviteCtxTimeOutTimer(OnWaitForAckTimeOut);

            if(_logger.IsDebugEnabled) _logger.Debug("Initialized.");
        }
Пример #2
0
 public SipAddressFactory CreateAddressFactory()
 {
     return _addressFactory ?? (_addressFactory = new SipAddressFactory());
 }
        /// <summary>
        /// creates a ack. this is to be sent by the testclient UA
        /// </summary>
        /// <param name="invite"></param>
        /// <param name="ringing"></param>
        /// <returns></returns>
        protected SipRequest CreateAckRequest(SipRequest invite, SipResponse ringing)
        {
            var addressFactory = new SipAddressFactory();
            var headerFactory = new SipHeaderFactory();
            var messageFactory = new SipMessageFactory();

            var localSequenceNr = invite.CSeq.Sequence;
            /*_remoteSequenceNr remains empty */
            var callId = invite.CallId.Value;
            var localTag = invite.From.Tag;
            var remoteUri = invite.To.SipUri;
            var localUri = invite.From.SipUri;

            var remoteTag = ringing.To.Tag;
            var remoteTarget = ringing.Contacts.GetTopMost().SipUri;
            var routeSet = ringing.RecordRoutes.ToList();//refuse looseroutin-less recordroutes
            routeSet.Reverse();

            var cseqHeader = headerFactory.CreateSCeqHeader(SipMethods.Ack, localSequenceNr);
            var toAddress = addressFactory.CreateAddress(null, remoteUri);
            var toHeader = headerFactory.CreateToHeader(toAddress, remoteTag);
            var fromAddress = addressFactory.CreateAddress(null, localUri);
            var fromHeader = headerFactory.CreateFromHeader(fromAddress, localTag);
            var callIdheader = headerFactory.CreateCallIdHeader(callId);
            var viaHeader = invite.Vias.GetTopMost();
            var requestUri = remoteUri.Clone();

            var maxForwardsHeader = headerFactory.CreateMaxForwardsHeader();
            var request = messageFactory.CreateRequest(
                requestUri,
                SipMethods.Ack,
                callIdheader,
                cseqHeader,
                fromHeader,
                toHeader,
                viaHeader,
                maxForwardsHeader);

            foreach (var route in routeSet)
            {
                request.Routes.Add(new SipRouteHeader() { SipUri = route.SipUri, Parameters = route.Parameters });
            }

            return request;
        }