Ejemplo n.º 1
0
        public void ProcessRequest(IInternalSoftPhone softPhone, Sip.Stack.SipRequestEvent requestEvent)
        {
            string method = requestEvent.Request.RequestLine.Method;

            _logger.Debug("processing request: {0} ...", method);

            if (method != SipMethods.Invite)
            {
                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug("Received request: '{0}'. Request ignored.", method);
                }
                return;
            }

            if (_logger.IsInfoEnabled)
            {
                _logger.Info("'INVITE' received. Creating 'RINGING' response...");
            }

            var ringingResponse = requestEvent.Request.CreateResponse(SipResponseCodes.x180_Ringing);

            ringingResponse.To.Tag = SipUtil.CreateTag();
            var contactUri = softPhone.AddressFactory.CreateUri("", softPhone.ListeningPoint.ToString());

            ringingResponse.Contacts.Add(softPhone.HeaderFactory.CreateContactHeader(contactUri));

            if (_logger.IsDebugEnabled)
            {
                _logger.Debug("Sending response ... ");
            }

            var serverTransaction = softPhone.SipProvider.CreateServerTransaction(requestEvent.Request);
            var dialog            = softPhone.SipProvider.CreateServerDialog(serverTransaction as SipInviteServerTransaction);

            serverTransaction.SendResponse(ringingResponse);
            requestEvent.IsSent = true;

            if (_logger.IsInfoEnabled)
            {
                _logger.Info("Response send. Transitioning to 'RINGING' state.");
            }

            softPhone.PendingInvite = new InviteInfo()
            {
                OriginalRequest = requestEvent.Request,
                RingingResponse = ringingResponse,
                From            = requestEvent.Request.From.SipUri,
                To = requestEvent.Request.To.SipUri,
                InviteServerTransaction = (SipInviteServerTransaction)serverTransaction,
                IsIncomingCall          = true,
                Dialog = dialog
            };

            softPhone.RaiseIncomingCall();/* !! the incoming call event is raised, before any callstate events can occur*/

            softPhone.ChangeState(softPhone.StateProvider.GetRinging());

            if (_logger.IsDebugEnabled)
            {
                _logger.Debug("'RINGING' response created. Raising Incoming PhoneCall...");
            }

            if (_logger.IsDebugEnabled)
            {
                _logger.Debug("Raised.");
            }
        }
Ejemplo n.º 2
0
 public void ProcessRequest(IInternalSoftPhone softPhone, Sip.Stack.SipRequestEvent requestEvent)
 {
 }