예제 #1
0
 internal override StateResult ProcessRequest(SipNonInviteServerTransaction ctx, SipRequestEvent request)
 {
     /*17.2.2. : While in the "Completed" state, the server transaction MUST pass the final response to the transport
     layer for retransmission whenever a retransmission of the request is received. */
     ctx.SendResponseInternal();
     return new StateResult();
 }
예제 #2
0
파일: Server.cs 프로젝트: HNeukermans/Hallo
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            WriteToLog(">>>>" + SipFormatter.FormatMessageEnvelope(requestEvent.Request) + Environment.NewLine);
            requestEvent.Response = requestEvent.Request.CreateResponse(SipResponseCodes.x200_Ok);
            requestEvent.IsHandled = true;
            _sipProvider.SendResponse(requestEvent.Response);

            WriteToLog("<<<<" + SipFormatter.FormatMessageEnvelope(requestEvent.Response) + Environment.NewLine);
        }
예제 #3
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            var enumerator = _requestHandlers.GetEnumerator();

            while (enumerator.MoveNext())
            {
                enumerator.Current.ProcessRequest(requestEvent);
                if (requestEvent.IsHandled)
                {
                    break;
                }
            }
        }
예제 #4
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            Console.WriteLine("Received '{0}' request", requestEvent.Request.CSeq.Command);

            var okResponse = requestEvent.Request.CreateResponse(SipResponseCodes.x200_Ok);

            var serverTransaction = _receiverProvider.CreateServerTransaction(requestEvent.Request);

            serverTransaction.SendResponse(okResponse);

            /*instruct the sipprovider that we have already sent the response*/
            requestEvent.IsSent = true;
        }
        public override void ProcessRequest(SipRequestEvent requestEvent)
        {
            requestEvent.ServerTransaction = this;
            StateResult result;

            lock (_lock)
            {
                result = _state.ProcessRequest(this, requestEvent);
            }
            if (result.InformToUser)
            {
                _listener.ProcessRequest(requestEvent);
            }
        }
예제 #6
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            var response = requestEvent.Request.CreateResponse(SipResponseCodes.x200_Ok);

            if (requestEvent.ServerTransaction != null)
            {
                requestEvent.ServerTransaction.SendResponse(response);
            }
            else
            {
                requestEvent.Response  = response;
                requestEvent.IsHandled = true;
                MainForm.SipProvider.SendResponse(requestEvent.Response);
            }
        }
예제 #7
0
            internal override StateResult ProcessRequest(SipInviteServerTransaction tx, SipRequestEvent requestEvent)
            {
                /* 17.2.1 If an ACK is received while the server transaction is in the
                   "Completed" state, the server transaction MUST transition to the
                   "Confirmed" state. */
                if (requestEvent.Request.RequestLine.Method == SipMethods.Ack)
                {
                    tx.ChangeState(SipInviteServerTransaction.ConfirmedState);
                }
                else
                {
                    tx.SendResponseInternal();
                }

                return new StateResult();
            }
예제 #8
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            string method = requestEvent.Request.RequestLine.Method;

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

            ValidateSipSchema(requestEvent.Request);

            ////not sure if this is the right place?
            //if (State is IdleState)
            //{
            //    throw new SipException(SipResponseCodes.x486_Busy_Here);
            //}

            InternalState.ProcessRequest(this, requestEvent);

            _logger.Debug("Request processed.");
        }
예제 #9
0
        private void SendErrorResponse(Exception exception, SipRequestEvent requestEvent)
        {
            Check.Require(exception, "exception");
            Check.Require(requestEvent, "requestEvent");
            Check.Require(requestEvent.Request, "requestEvent.Request");

            var request      = requestEvent.Request;
            var sipException = exception as SipException;

            string      responseCode = sipException != null ? sipException.ResponseCode : SipResponseCodes.x500_Server_Internal_Error;
            SipResponse response     = sipException != null?_stack.CreateMessageFactory().CreateResponse(request, responseCode) :
                                           _stack.CreateMessageFactory().CreateResponse(request, responseCode + ", " + exception.Message);

            if (requestEvent.ServerTransaction != null)
            {
                requestEvent.ServerTransaction.SendResponse(response);
            }
            else if (response.Vias.GetTopMost() != null)
            {
                IPEndPoint ipEndPoint = SipProvider.DetermineSendTo(response);

                try
                {
                    _contextSource.SendTo(SipFormatter.FormatMessage(response), ipEndPoint);
                    if (_responseSentObserver != null)
                    {
                        _responseSentObserver.OnNext(response);
                    }
                }
                catch (SocketException err)
                {
                    _logger.Error("Failed to send response to " + ipEndPoint.ToString(), err);
                }
            }
            else
            {
                _logger.Warn("Response can not be sent. Via TopMost header missing.");
            }
        }
예제 #10
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            if (requestEvent.Request.RequestLine.Method == SipMethods.Invite)
            {
                var inviteTransaction = (SipInviteServerTransaction)_provider.CreateServerTransaction(requestEvent.Request);
                var dialog            = _provider.CreateServerDialog(inviteTransaction);

                /*let the phone of the receiver ring to indicate someone is calling to you+
                *  send back a ringing response to inform to callee, you received the invite*/
                WavePlayer player = new WavePlayer(AudioOut.Devices[0]);
                player.Play(ResManager.GetStream("ringing.wav"), 10);
                var response = CreateRingingResponse(requestEvent.Request);
                inviteTransaction.SendResponse(response);

                //start timer that does the above untill the dialog state != Early
                //the listener is in some state. In this state the callee can answer or cancel the call.
                //when it does it goes to another state.
            }
            else if (requestEvent.Request.RequestLine.Method == SipMethods.Ack &&
                     requestEvent.Request.CSeq.Command == SipMethods.Invite)
            {
                /*TODO: */
            }
        }
예제 #11
0
 internal override StateResult ProcessRequest(SipInviteServerTransaction transaction, SipRequestEvent request)
 {
     return(new StateResult());
 }
예제 #12
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            var request     = requestEvent.Request;
            var requestLine = request.RequestLine;
            var toUri       = request.To.SipUri;
            var aor         = toUri.FormatToString();
            var newContacts = request.Contacts.ToList();

            if (requestLine.Method == SipMethods.Register)
            {
                if (!string.IsNullOrWhiteSpace(requestLine.Uri.User))
                {
                    /*throw invalid exception bc the user portion for a register request must be empty*/
                    throw new SipException(SipResponseCodes.x400_Bad_Request, "The sip uri can not contain a user.");
                }

                /*10.3. 1. The registrar inspects the Request-URI to determine whether it
                 * has access to bindings for the domain identified in the
                 * Request-URI.  If not, and if the server also acts as a proxy
                 * server, the server SHOULD forward the request to the addressed
                 * domain, following the general behavior for proxying messages
                 * described in Section 16.*/

                /*The registrar inspects the Request-URI to determine whether it
                 * has access to bindings for the domain identified in the Request-URI.
                 * Here we give an exception back to the client because we only supports single domain */

                if (requestLine.Uri.Host != _settings.Domain)
                {
                    throw new SipException(SipResponseCodes.x404_Not_Found);
                }

                if (toUri.Host != _settings.Domain)
                {
                    /*If the address-of-record is not valid for the domain in the Request-URI,
                     * the registrar MUST send a 404 (Not Found) response and skip the remaining steps.*/
                    throw new SipException(SipResponseCodes.x404_Not_Found);
                }

                bool hasWildCard = newContacts.Any(c => c.IsWildCard);
                if (hasWildCard)
                {
                    if (IsInvalidWildCardRequest(request))
                    {
                        throw new SipException(SipResponseCodes.x400_Bad_Request);
                    }

                    /*case: deregister: remove all bindings for the aor */
                    foreach (var binding in _addressBindingService.GetByAddressOfRecord(aor))
                    {
                        if (binding.CallId != request.CallId.Value)
                        {
                            _addressBindingService.Remove(binding);
                            continue;
                        }
                        if (request.CSeq.Sequence > binding.CSeq)
                        {
                            _addressBindingService.Remove(binding);
                        }
                    }
                }

                /*The registrar extracts the address-of-record from the To header
                *   field of the request. If the address-of-record is not valid
                *   for the domain in the Request-URI, the registrar MUST send a
                *   404 (Not Found) response and skip the remaining steps.  The URI
                *   MUST then be converted to a canonical form.  To do that, all
                *   URI parameters MUST be removed (including the user-param), and
                *   any escaped characters MUST be converted to their unescaped
                *   form.  The result serves as an index into the list of bindings.*/
                /* Each binding record records the Call-ID and CSeq values from the request.*/
                foreach (var contact in newContacts)
                {
                    if (!SipUtil.IsIPAddress(contact.SipUri.Host))
                    {
                        throw new SipException(SipResponseCodes.x400_Bad_Request, "Contact uri must have numeric IP format.");
                    }
                    var host = new IPEndPoint(SipUtil.ParseIpAddress(contact.SipUri.Host), contact.SipUri.Port);

                    int expires = _settings.DefaultExpires;
                    if (request.Expires != null)
                    {
                        expires = request.Expires.Value;
                    }
                    if (contact.Expires.HasValue)
                    {
                        expires = contact.Expires.Value;
                    }

                    var newAddressBinding =
                        new SipAddressBinding(
                            aor,
                            host,
                            request.CSeq.Sequence,
                            request.CallId.Value,
                            expires);

                    if (expires == 0)
                    {
                        _addressBindingService.Remove(newAddressBinding);
                    }
                    else if (expires < _settings.MinimumExpires)
                    {
                        throw new SipException(SipResponseCodes.x423_Interval_Too_Brief);
                    }
                    else
                    {
                        _addressBindingService.AddOrUpdate(newAddressBinding);
                    }
                }

                var okResponse        = request.CreateResponse(SipResponseCodes.x200_Ok);
                var contactsAddresses = new List <SipContactHeader>();

                foreach (var binding in _addressBindingService.GetByAddressOfRecord(aor))
                {
                    var contactAddress = new SipContactHeader();
                    contactAddress.Expires = (int)(binding.EndTime - DateTime.Now).TotalSeconds;
                    contactAddress.SipUri  = new SipUri()
                    {
                        Host = binding.Host.Address.ToString(),
                        Port = binding.Host.Port
                    };
                    contactsAddresses.Add(contactAddress);
                }

                contactsAddresses.ForEach(okResponse.Contacts.Add);

                /*set the response*/
                if (requestEvent.ServerTransaction != null)
                {
                    requestEvent.ServerTransaction.SendResponse(okResponse);
                    requestEvent.IsHandled = true;
                    requestEvent.IsSent    = true;
                }
                else
                {
                    requestEvent.Response  = okResponse;
                    requestEvent.IsHandled = true;
                }
            }
        }
 public abstract void ProcessRequest(SipRequestEvent requestEvent);
예제 #14
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            Log("Received a request. RequestLine:'{0}'", requestEvent.Request.RequestLine.FormatToString());

            if (requestEvent.Request.RequestLine.Method == SipMethods.Invite)
            {
                Log("Received an INVITE request.");
                if (_state == PhoneState.Idle)
                {
                    _inviteRequest = requestEvent.Request;
                    _ringingRetransmitSubscription = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(5)).ObserveOn(this).Subscribe((i) =>
                    {
                        Log("Sending a ringing response...");
                        SendRinging();
                        Log("Ringing response send.");
                        if (i == 0)
                        {
                            GoToState(PhoneState.Ringing);
                            RefreshDialogForm(_dialog);
                        }
                    });
                }
                else
                {
                    Log("Currently busy...");
                    //send busy here
                }
            }


            if (_state == PhoneState.Idle)
            {
                if (requestEvent.Request.RequestLine.Method == SipMethods.Invite)
                {
                    GoToState(PhoneState.Ringing);
                    _pendingRequestEvent = requestEvent;

                    this.OnUIThread(() =>
                    {
                        //show the name of the caller in the from textboxes.
                        _txtFromAlias.Text = requestEvent.Request.From.DisplayInfo;
                        _txtFromAlias.Text = requestEvent.Request.From.DisplayInfo;
                        //clear all other from-to textboxes
                        _txtFromUri.Text = ""; requestEvent.Request.From.SipUri.FormatToString();
                        _txtToUri.Text   = _txtToAlias.Text = "";
                    });

                    //block the processing thread
                    _waitHandle.WaitOne(30 * 1000);
                }
            }
            else if (_state == PhoneState.Ringing)
            {
                if (requestEvent.Request.RequestLine.Method == SipMethods.Cancel)
                {
                    //TODO: send 487 + stop ringing
                    GoToState(PhoneState.Idle);
                }
            }
            else if (_state == PhoneState.WaitingForAck)
            {
                if (requestEvent.Request.RequestLine.Method == SipMethods.Ack)
                {
                    Log("Received an ACK request. Going to 'CALLERESTABLISHED' state");
                    GoToState(PhoneState.CallerEstablished);
                }
            }
            else if (_state == PhoneState.CallerEstablished)
            {
                if (requestEvent.Request.RequestLine.Method == SipMethods.Bye)
                {
                    Debugger.Break();
                    Log("Received an BYE request.");
                    Log("Sending a OK response...");
                    /*send ok*/
                    var okResponse        = requestEvent.Request.CreateResponse(SipResponseCodes.x200_Ok);
                    var serverTransaction = SipProvider.CreateServerTransaction(requestEvent.Request);
                    serverTransaction.SendResponse(okResponse);
                    Log("OK response send.");
                    if (requestEvent.Dialog != null)
                    {
                        requestEvent.Dialog.Terminate();
                        Log("Terminating dialog.");
                    }
                    GoToState(PhoneState.Idle);
                }
            }
        }
 public void ProcessRequest(SipRequestEvent requestEvent)
 {
     throw new NotImplementedException();
 }
 public override void ProcessRequest(SipRequestEvent requestEvent)
 {
     requestEvent.ServerTransaction = this;
     StateResult result;
     lock (_lock)
     {
         result = _state.ProcessRequest(this, requestEvent);
     }
     if (result.InformToUser)
     {
         _listener.ProcessRequest(requestEvent);
     }
 }
예제 #17
0
        private void OnIncomingRequestContext(SipContext context)
        {
            if (_requestReceivedObserver != null)
            {
                _requestReceivedObserver.OnNext(context.Request);
            }

            if (_logger.IsDebugEnabled)
            {
                _logger.Debug("Validating the request...");
            }

            var result = new SipValidator().ValidateMessage(context.Request);

            if (!result.IsValid)
            {
                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug("The received request is not valid. Throwing a sip exception.");
                }

                ThrowSipException(result);
            }

            if (_logger.IsDebugEnabled)
            {
                _logger.Debug("Request valid.");
            }

            /*firewall traversal not supported. SupportFirewalTraversal(context);*/

            var requestEvent = new SipRequestEvent(context);

            ISipRequestProcessor sipRequestProcessor = _sipListener;

            //8.2.2.2: merged requests, not implemented

            SipAbstractServerTransaction stx;

            if (_logger.IsDebugEnabled)
            {
                _logger.Debug("Searching the table for a matching tx..");
            }

            if (_stxTable.TryGetValue(GetServerTransactionId(context.Request), out stx))
            {
                if (_logger.IsTraceEnabled)
                {
                    _logger.Trace("Found a matching tx. Setting it as the requestprocessor.");
                }

                sipRequestProcessor = stx;

                //if (IsDialogInitiatingRequest(stx.Request))
                //{
                //if (_logger.IsDebugEnabled) _logger.Debug("The received request is an 'INVITE' request. Try setting the dialog on tx...");

                //set the dialog, so it can initiate
                SipAbstractDialog found;
                if (TryGetDialogOnTx(context.Request, out found))
                {
                    requestEvent.Dialog = found;
                }
                //}
            }
            else
            {
                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug("Could not find a matching tx..");
                }

                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug("Searching the table for a matching dialog...");
                }

                SipAbstractDialog dialog;
                if (_dialogTable.TryGetValue(GetDialogId(context.Request, true), out dialog))
                {
                    if (_logger.IsTraceEnabled)
                    {
                        _logger.Trace("Found a matching dialog. Setting it as the requestprocessor.");
                    }

                    sipRequestProcessor = dialog;
                    requestEvent.Dialog = dialog;
                }
                else
                {
                    if (_logger.IsTraceEnabled)
                    {
                        _logger.Trace("Could not find a matching dialog. Using the SipProvider's SipListener as the requestprocessor.");
                    }
                }
            }

            try
            {
                sipRequestProcessor.ProcessRequest(requestEvent);

                if (requestEvent.IsSent)
                {
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug("Processed '{0}' request. The response has already been sent. Skipping automatic response sending.", requestEvent.Request.RequestLine.Method);
                    }
                    return;
                }

                if (!ShouldHaveResponse(requestEvent.Request))
                {
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug("Processed '{0}' request. The request does not require a response. Skipping automatic response sending.", requestEvent.Request.RequestLine.Method);
                    }
                    return;
                }

                if (requestEvent.Response == null)
                {
                    throw new SipCoreException("Response to send can not be null. The ProcessRequest method is supposed to create a response message that is to be sent.");
                }

                if (!requestEvent.IsSent)
                {
                    var response = requestEvent.Response;

                    var remoteEndPoint = SipProvider.DetermineSendTo(response);

                    _contextSource.SendTo(SipFormatter.FormatMessage(response), remoteEndPoint);

                    if (_responseSentObserver != null)
                    {
                        _responseSentObserver.OnNext(response);
                    }
                }
            }
            catch (SipCoreException coreException)
            {
                throw coreException;
            }
            catch (SipException sipException)
            {
                if (ShouldHaveResponse(requestEvent.Request))
                {
                    SendErrorResponse(sipException, requestEvent);
                }
            }
            catch (Exception err)
            {
                _logger.ErrorException("Request failed.", err);

                try
                {
                    if (ShouldHaveResponse(requestEvent.Request))
                    {
                        SendErrorResponse(err, requestEvent);
                    }
                }
                catch (Exception errr)
                {
                    _logger.Debug("Failed to send the response.", errr);
                }
            }
        }
예제 #18
0
 protected abstract void ProcessRequestOverride(DialogResult result, SipRequestEvent requestEvent);
예제 #19
0
 internal override StateResult ProcessRequest(SipNonInviteServerTransaction ctx, SipRequestEvent request)
 {
     /*17.2.2.: retransmitted requests in the trying state should be discarded.*/
     return new StateResult();
 }
예제 #20
0
 public void ProcessRequest(SipRequestEvent requestEvent)
 {
     OnProcessRequest(requestEvent);
 }
예제 #21
0
            internal override StateResult ProcessRequest(SipInviteServerTransaction tx, SipRequestEvent requestEvent)
            {
                /* 17.2.1 If an ACK is received while the server transaction is in the
                 * "Completed" state, the server transaction MUST transition to the
                 * "Confirmed" state. */
                if (requestEvent.Request.RequestLine.Method == SipMethods.Ack)
                {
                    tx.ChangeState(SipInviteServerTransaction.ConfirmedState);
                }
                else
                {
                    tx.SendResponseInternal();
                }

                return(new StateResult());
            }
예제 #22
0
 internal override StateResult ProcessRequest(SipNonInviteServerTransaction ctx, SipRequestEvent request)
 {
     /*17.2.2.: retransmitted requests in the trying state should be discarded.*/
     return(new StateResult());
 }
예제 #23
0
 internal abstract StateResult ProcessRequest(SipNonInviteServerTransaction ctx, SipRequestEvent request);
예제 #24
0
 internal void Update(SipRequestEvent requestEvent)
 {
     Response  = requestEvent.Response;
     IsHandled = requestEvent.IsHandled;
     IsSent    = requestEvent.IsSent;
 }
예제 #25
0
 internal abstract StateResult ProcessRequest(SipInviteServerTransaction transaction, SipRequestEvent request);
예제 #26
0
 protected virtual void AfterPhoneProcessedRequest(IInternalSoftPhone softPhone, SipRequestEvent requestEvent)
 {
 }
예제 #27
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            if (_logger.IsDebugEnabled) _logger.Debug("Dialog[Id={0}] received as request[method={1}]", GetId(), requestEvent.Request.RequestLine.Method);
            var result = new DialogResult();
            result.InformToUser = true;

            var seqNr = requestEvent.Request.CSeq.Sequence;

            /* If the remote sequence number is empty, it MUST be set to the value
              of the sequence number in the CSeq header field value in the request.
              If the remote sequence number was not empty, but the sequence number
              of the request is lower than the remote sequence number, the request
              is out of order and MUST be rejected with a 500 (Server Internal
              Error) response. remoteSequenceNr = unset value = -1*/

            if (seqNr < _remoteSequenceNr)
            {
                throw new SipException(SipResponseCodes.x500_Server_Internal_Error);
            }

            _remoteSequenceNr = seqNr;

            ProcessRequestOverride(result, requestEvent);

            if(result.InformToUser)
            {
                /*forward TODO: check rfc*/
                _listener.ProcessRequest(requestEvent);
            }
        }
예제 #28
0
 internal override StateResult ProcessRequest(SipNonInviteServerTransaction tx, SipRequestEvent request)
 {
     tx.SendResponseInternal();
     return new StateResult();
 }
예제 #29
0
 internal override StateResult ProcessRequest(SipNonInviteServerTransaction tx, SipRequestEvent request)
 {
     tx.SendResponseInternal();
     return(new StateResult());
 }
예제 #30
0
        public void ProcessRequest(IInternalSoftPhone softPhone, SipRequestEvent requestEvent)
        {
            string method = requestEvent.Request.RequestLine.Method;

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

            if (_logger.IsInfoEnabled)
            {
                _logger.Info("'CANCEL' received. Start processing...");
            }

            #region attempt to match transaction

            /*terminate pending invite with 487 (assumption: PendingInvite.OriginalRequest= requestEvent.ServerTransaction.Request)*/

            if (_logger.IsDebugEnabled)
            {
                _logger.Debug("Attempting to match 'CANCEL' target-tx against a tx in the ServerTransactionTable...");
            }

            var txIdAttempts = CreateTxIdAttempts(requestEvent.Request);

            ISipServerTransaction serverTransaction = null;
            foreach (var txIdAttempt in txIdAttempts)
            {
                serverTransaction = softPhone.SipProvider.FindServerTransactionById(txIdAttempt);
                if (serverTransaction != null)
                {
                    break;
                }
            }

            #endregion

            if (serverTransaction == null)
            {
                #region no match

                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug("Could not match 'CANCEL' to an existing transaction. Sending x487 response...");
                }

                var cancelResponse = requestEvent.Request.CreateResponse(SipResponseCodes.x481_Call_Transaction_Does_Not_Exist);
                var cancelTx       = softPhone.SipProvider.CreateServerTransaction(requestEvent.Request);
                cancelTx.SendResponse(cancelResponse);
                requestEvent.IsSent = true;

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

                #endregion
            }
            else
            {
                #region matched

                #region respond to cancel with ok

                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug("'CANCEL' target-tx matched. Answering to cancel with ok...");
                }

                var cancelOkResponse = requestEvent.Request.CreateResponse(SipResponseCodes.x200_Ok);
                var cancelOkTx       = softPhone.SipProvider.CreateServerTransaction(requestEvent.Request);
                cancelOkTx.SendResponse(cancelOkResponse);
                requestEvent.IsSent = true;

                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug("Answered.");
                }

                #endregion

                #region respond to matched tx with x487

                if (serverTransaction.GetId() != softPhone.PendingInvite.InviteServerTransaction.GetId())
                {
                    if (_logger.IsInfoEnabled)
                    {
                        _logger.Info("'CANCEL' target-tx does NOT match 'INVITE.' Processing ABORTED. The 'CANCEL' target-tx is expected, to match only to the pending 'INVITE' servertransaction.");
                    }
                }
                else
                {
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug("Creating '487-Request terminated' response and sending...");
                    }

                    var requestToCancel   = serverTransaction.Request;
                    var terminateResponse = requestToCancel.CreateResponse(SipResponseCodes.x487_Request_Terminated);

                    /*terminate pending invite.*/
                    softPhone.PendingInvite.InviteServerTransaction.SendResponse(terminateResponse);

                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug("Response send.");
                    }

                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug("Changing callstate to 'CANCELLED'.");
                    }

                    softPhone.PendingCall.RaiseCallStateChanged(CallState.Cancelled);

                    if (_logger.IsInfoEnabled)
                    {
                        _logger.Info("'CANCEL' Processed. Transitioning (back) to 'Idle'");
                    }

                    softPhone.ChangeState(softPhone.StateProvider.GetIdle());
                }

                #endregion

                #endregion
            }
        }
예제 #31
0
        public void ProcessRequest(SipRequestEvent requestEvent)
        {
            Console.WriteLine("Received '{0}' request on {1}", requestEvent.Request.CSeq.Command, DateTime.Now.ToString("hh:mm:ss"));

            requestEvent.IsSent = true;
        }
예제 #32
0
 protected override void ProcessRequestOverride(DialogResult result, SipRequestEvent requestEvent)
 {
 }
예제 #33
0
 protected abstract void ProcessRequestOverride(DialogResult result, SipRequestEvent requestEvent);
        public override void ProcessRequest(SipRequestEvent requestEvent)
        {
            requestEvent.ServerTransaction = this;
            StateResult result;
            lock (_lock)
            {
                result = _state.ProcessRequest(this, requestEvent);
            }
            if(result.InformToUser)
            {
                if (GetDialog() != null)
                {
                    if (_logger.IsDebugEnabled) _logger.Debug("Tx is holding a dialog. Invoking ProcessResponse on Dialog.");

                    GetDialog().ProcessRequest(requestEvent);
                }
                else
                {
                    if (_logger.IsDebugEnabled) _logger.Debug("Passing response to listener: '{0}'", _listener.GetType().Name);

                    _listener.ProcessRequest(requestEvent);
                }
            }
        }
예제 #35
0
 protected override void ProcessRequestOverride(DialogResult result, SipRequestEvent requestEvent)
 {
 }
예제 #36
0
 internal override StateResult ProcessRequest(SipInviteServerTransaction transaction, SipRequestEvent request)
 {
     return new StateResult();
 }
예제 #37
0
 public abstract void ProcessRequest(SipRequestEvent requestEvent);
예제 #38
0
 protected override void AfterPhoneProcessedRequest(IInternalSoftPhone softPhone, SipRequestEvent requestEvent)
 {
     if (requestEvent.Request.CSeq.Command == SipMethods.Invite)
     {
         _waitingforInviteReceived.Set();
     }
 }
예제 #39
0
 internal override StateResult ProcessRequest(SipNonInviteServerTransaction ctx, SipRequestEvent request)
 {
     /*17.2.2. : While in the "Completed" state, the server transaction MUST pass the final response to the transport
      * layer for retransmission whenever a retransmission of the request is received. */
     ctx.SendResponseInternal();
     return(new StateResult());
 }