protected override void OnTestClientUaReceive(SipContext sipContext)
 {
     if (sipContext.Request.RequestLine.Method == SipMethods.Invite)
     {
         _waitingforInviteReceived.Set();
     }
 }
Exemplo n.º 2
0
 protected override void OnTestClientUaReceive(SipContext sipContext)
 {
     if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x180_Ringing)
     {
         if (_receivedRingingResponse == null) _receivedRingingResponse = sipContext.Response;
     }
 }
Exemplo n.º 3
0
        private SipContext CreateSipContext(SipMessage message, Datagram datagram)
        {
            var request  = message as SipRequest;
            var response = message as SipResponse;

            if (request != null)
            {
                _logger.Debug("Request Received '" + request.RequestLine.Method + " " + request.RequestLine.Uri.FormatToString() + "' from " +
                              datagram.RemoteEndPoint);
            }
            else
            {
                _logger.Debug("Response Received '" + response.StatusLine.StatusCode + " " + response.StatusLine.ReasonPhrase + "' from " +
                              datagram.RemoteEndPoint);
            }

            var c = new SipContext();

            _logger.Trace("Parse on parser context completed.");

            c.Request        = request;
            c.Response       = response;
            c.RemoteEndPoint = datagram.RemoteEndPoint;
            c.LocalEndPoint  = datagram.LocalEndPoint;

            return(c);
        }
 protected override void GivenOverride()
 {
     /*fire ringing response to forec the dialog to go into early state*/
     var c = new SipContext();
     _response = CreateRingingResponse();
     c.Response = _response;
     _contextSource.FireNewContextReceivedEvent(c);
 }
 protected override void When()
 {
     /*create ringing response*/
     var c = new SipContext();
     _response = CreateRingingResponse();
     c.Response = _response;
     _contextSource.FireNewContextReceivedEvent(c);
 }
Exemplo n.º 6
0
 protected SipResponseEvent CreateFinalResponseEvent()
 {
     var statusLine = new SipStatusLineBuilder().WithStatusCode(200).WithReason("OK").Build();
     var r = new SipResponseBuilder().WithStatusLine(statusLine).Build();
     var c = new SipContext();
     c.Response = r;
     return new SipResponseEvent(c);
 }
        protected override void OnTestClientUaReceive(SipContext sipContext)
        {
            _counter++;
            if( _counter == 2) _wait.Set();

            /*continue test execution*/
            //_wait.Set(); move to statechanged, as this is the last event in code.
        }
 protected override void When()
 {
     /*fire ok response*/
     var c = new SipContext();
     _response = CreateOkResponse();
     _response.To.Tag = "different";
     c.Response = _response;
     _contextSource.FireNewContextReceivedEvent(c);
 }
Exemplo n.º 9
0
 private void OnNewContextReceived(SipContext context)
 {
     if (context.Request != null)
     {
         OnIncomingRequestContext(context);
     }
     else
     {
         OnIncomingResponseContext(context);
     }
 }
Exemplo n.º 10
0
        protected override void OnTestClientUaReceive(SipContext sipContext)
        {
            if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x180_Ringing)
            {
                _receivedRingingResponse = sipContext.Response;
            }

            if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x200_Ok)
            {
                _waitingforOkReceived.Set();
            }
        }
Exemplo n.º 11
0
 protected override void OnTestClientUaReceive(SipContext sipContext)
 {
     if (sipContext.Request.RequestLine.Method == SipMethods.Invite)
     {
         _receivedInvite = sipContext.Request;
         _waitingforInviteReceived.Set();
     }
     else if (sipContext.Request.RequestLine.Method == SipMethods.Ack)
     {
         _receivedAck = sipContext.Request;
         _waitingForAckReceived.Set();
     }
 }
Exemplo n.º 12
0
        private SipContext CreateSipContext(SipMessage message, Datagram datagram)
        {
            var request = message as SipRequest;
            var response = message as SipResponse;

            var c = new SipContext();

            c.Request = request;
            c.Response = response;
            c.RemoteEndPoint = datagram.RemoteEndPoint;
            c.LocalEndPoint = datagram.LocalEndPoint;

            return c;
        }
Exemplo n.º 13
0
 protected override void OnTestClientUaReceive(SipContext sipContext)
 {
     if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x180_Ringing)
     {
         lock (_lock)
         {
             _ringingReceivedCounter++;
             if (_ringingReceivedCounter > (_longtimeSpan / _periodicity))
             {
                 _wait.Set();
             }
         }
     }
 }
Exemplo n.º 14
0
        public SipContext CreateContext(Datagram datagram)
        {
            Check.Require(datagram, "datagram");

            _logger.Trace("Calling CreateContext...");

            var        parserContext = new SipParserContext(_messageFactory, _headerFactory);
            SipContext context       = null;

            parserContext.ParseCompleted += (s, e) => context = ParserContext_ParseCompleted(e, datagram);

            _logger.Trace("Calling Parse on parser context...");
            parserContext.Parse(datagram.DataBytes);
            return(context);
        }
 protected override void OnTestClientUaReceive(SipContext sipContext)
 {
     if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x180_Ringing)
     {
         _receivedRingingResponse = sipContext.Response;
     }
     if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x200_Ok)
     {
         _waitingforOkReceived.Set();
     }
     if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x200_Ok &&
         sipContext.Response.CSeq.Command == SipMethods.Bye)
     {
         _receivedOkByeResponse = sipContext.Response;
         _waitForByeReceived.Set();
     }
 }
Exemplo n.º 16
0
        protected override void OnTestClientUaReceive(SipContext sipContext)
        {
            if (sipContext.Response != null && sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x180_Ringing)
            {
                _receivedRingingResponse = sipContext.Response;
            }

            if (sipContext.Response != null && sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x200_Ok)
            {
                _waitingforOkReceived.Set();
            }

            if (sipContext.Request != null && sipContext.Request.RequestLine.Method == SipMethods.Bye)
            {
                _receivedBye = sipContext.Request;
                _waitForByeReceived.Set();
            }
        }
Exemplo n.º 17
0
        SipContext ParserContext_ParseCompleted(ParseCompletedEventArgs e, Datagram datagram)
        {
            var c = new SipContext();

            _logger.Trace("Parse on parser context completed.");

            c.Request = e.Message as SipRequest;
            c.Response = e.Message as SipResponse;
            c.RemoteEndPoint = datagram.RemoteEndPoint;
            c.LocalEndPoint = datagram.LocalEndPoint;

            if (c.Request != null)
                _logger.Debug("Request Received '" + c.Request.RequestLine.Method + " " + c.Request.RequestLine.Uri.FormatToString() + "' from " +
                              datagram.RemoteEndPoint);

            if (c.Response != null)
                _logger.Debug("Response Received '" + c.Response.StatusLine.StatusCode + " " + c.Response.StatusLine.ReasonPhrase + "' from " +
                              datagram.RemoteEndPoint);
            return c;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Only use this if NAT traversal is to be supported. Sets the Received + Rport parameters
        /// </summary>
        /// <param name="context"></param>
        internal static void SupportFirewalTraversal(SipContext context)
        {
            Check.Require(context, "context");
            Check.Require(context.Request, "context.Request");
            Check.Require(context, "context");

            var request    = context.Request;
            var topMostVia = request.Vias.GetTopMost();

            //Support NAT firewal
            if (!topMostVia.SentBy.Address.Equals(context.RemoteEndPoint.Address))
            {
                topMostVia.Received = context.RemoteEndPoint.Address;
            }

            //Support PAT firewall. Rfc3581 is not supported. TODO: remove.
            if (topMostVia.UseRport)
            {
                topMostVia.Rport = context.RemoteEndPoint.Port;
            }
        }
 protected override void OnTestClientUaReceive(SipContext sipContext)
 {
     if (sipContext.Response != null)
     {
         if (sipContext.Response.CSeq.Command == SipMethods.Invite)
         {
             if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x180_Ringing)
             {
                 if (_receivedRingingResponse == null) _receivedRingingResponse = sipContext.Response;
             }
             else if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x487_Request_Terminated)
             {
                 /**/
                 waitHandles[0].Set();
             }
         }
         else if (sipContext.Response.CSeq.Command == SipMethods.Cancel && sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x200_Ok)
         {
             /*receive ok to cancel*/
             waitHandles[1].Set();
         }
     }
 }
Exemplo n.º 20
0
        SipContext ParserContext_ParseCompleted(ParseCompletedEventArgs e, Datagram datagram)
        {
            var c = new SipContext();

            _logger.Trace("Parse on parser context completed.");

            c.Request        = e.Message as SipRequest;
            c.Response       = e.Message as SipResponse;
            c.RemoteEndPoint = datagram.RemoteEndPoint;
            c.LocalEndPoint  = datagram.LocalEndPoint;

            if (c.Request != null)
            {
                _logger.Debug("Request Received '" + c.Request.RequestLine.Method + " " + c.Request.RequestLine.Uri.FormatToString() + "' from " +
                              datagram.RemoteEndPoint);
            }

            if (c.Response != null)
            {
                _logger.Debug("Response Received '" + c.Response.StatusLine.StatusCode + " " + c.Response.StatusLine.ReasonPhrase + "' from " +
                              datagram.RemoteEndPoint);
            }
            return(c);
        }
 public void ProcessResponse(SipResponse sipResponse, SipContext context)
 {
     lock (_locker) Responses.Add(sipResponse);
     _onRecievedResponse(sipResponse, context);
 }
Exemplo n.º 22
0
        /// <summary>
        /// Only use this if NAT traversal is to be supported. Sets the Received + Rport parameters
        /// </summary>
        /// <param name="context"></param>
        internal static void SupportFirewalTraversal(SipContext context)
        {
            Check.Require(context, "context");
            Check.Require(context.Request, "context.Request");
            Check.Require(context, "context");

            var request = context.Request;
            var topMostVia = request.Vias.GetTopMost();

            //Support NAT firewal
            if (!topMostVia.SentBy.Address.Equals(context.RemoteEndPoint.Address))
            {
                topMostVia.Received = context.RemoteEndPoint.Address;
            }

            //Support PAT firewall. Rfc3581 is not supported. TODO: remove.
            if (topMostVia.UseRport)
            {
                topMostVia.Rport = context.RemoteEndPoint.Port;
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// determines the send to
        /// </summary>
        /// <remarks>in case via header is missing returns the socket remote endpoint</remarks>
        private static IPEndPoint DetermineSendTo(SipContext context)
        {
            var response = context.Response;

            return DetermineSendTo(response);
        }
Exemplo n.º 24
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);
                }
            }
        }
Exemplo n.º 25
0
        private void OnIncomingResponseContext(SipContext context)
        {
            if (_responseReceivedObserver != null)
            {
                _responseReceivedObserver.OnNext(context.Response);
            }

            ISipResponseProcessor sipResponseProcessor = _sipListener;

            var responseEvent = new SipResponseEvent(context);

            //get dialog. if dialog found, the listener for the tx is the dialog.
            SipAbstractClientTransaction ctx;

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

            if (_ctxTable.TryGetValue(GetClientTransactionId(responseEvent.Response), out ctx))
            {
                if (_logger.IsTraceEnabled)
                {
                    _logger.Trace("Found a matching tx. Setting it as the responseProcessor.");
                }

                sipResponseProcessor = ctx;

                SipAbstractDialog found;

                if (ctx.GetDialog() == null)
                {
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug("Searching the table for a matching dialog...");
                    }
                    if (_dialogTable.TryGetValue(GetDialogId(responseEvent.Response, false), out found))
                    {
                        if (_logger.IsDebugEnabled)
                        {
                            _logger.Debug("Found a matching dialog.");
                        }

                        ctx.SetDialog(found);
                    }
                    else
                    {
                        if (_logger.IsDebugEnabled)
                        {
                            _logger.Debug("A matching dialog could not be 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...");
                }

                /*try dialog as processor*/
                SipAbstractDialog dialog;
                if (_dialogTable.TryGetValue(GetDialogId(responseEvent.Response, false), out dialog))
                {
                    if (_logger.IsTraceEnabled)
                    {
                        _logger.Trace("Found a matching dialog. Setting it as the responseProcessor.");
                    }

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

            try
            {
                sipResponseProcessor.ProcessResponse(responseEvent);
            }
            catch (Exception err)
            {
                _logger.ErrorException("Response failed.", err);
                throw;
            }
        }
Exemplo n.º 26
0
 private void OnNewContextReceived(SipContext context)
 {
     if (context.Request != null)
     {
         OnIncomingRequestContext(context);
     }
     else
     {
         OnIncomingResponseContext(context);
     }
 }
Exemplo n.º 27
0
 /// <summary>
 /// fakes a new incoming message received from the socket that is already build up to a sipcontext.
 /// Directly invokes the SipProvider's OnNext method.
 /// </summary>
 /// <param name="sipContext"></param>
 internal void FireNewContextReceivedEvent(SipContext sipContext)
 {
     /*let the SipProvider know*/
     try
     {
         NewContextReceived(this, new SipContextReceivedEventArgs { Context = sipContext });
     }
     catch (Exception e)
     {
         UnhandledException(this,new ExceptionEventArgs(){ Exception = e});
     }
 }
Exemplo n.º 28
0
        protected SipResponseEvent CreateProvisionalResponseEvent()
        {
            var statusLine = new SipStatusLineBuilder().WithStatusCode(180).WithReason("Ringing").Build();
            var r = new SipResponseBuilder().WithStatusLine(statusLine).Build();

            var c = new SipContext();
            c.Response = r;
            return new SipResponseEvent(c);
        }
Exemplo n.º 29
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);
                }
            }
        }
 public void ProcessRequest(SipRequest sipRequest, SipContext context)
 {
     lock (_locker) Requests.Add(sipRequest);
     _onRecievedRequest(sipRequest, context);
 }
Exemplo n.º 31
0
        private void OnIncomingResponseContext(SipContext context)
        {
            if (_responseReceivedObserver != null) _responseReceivedObserver.OnNext(context.Response);

            ISipResponseProcessor sipResponseProcessor = _sipListener;

            var responseEvent = new SipResponseEvent(context);

             //get dialog. if dialog found, the listener for the tx is the dialog.
            SipAbstractClientTransaction ctx;

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

            if(_ctxTable.TryGetValue(GetClientTransactionId(responseEvent.Response), out ctx))
            {
                if (_logger.IsTraceEnabled) _logger.Trace("Found a matching tx. Setting it as the responseProcessor.");

                sipResponseProcessor = ctx;

                SipAbstractDialog found;

                if (ctx.GetDialog() == null)
                {
                    if (_logger.IsDebugEnabled) _logger.Debug("Searching the table for a matching dialog...");
                    if(_dialogTable.TryGetValue(GetDialogId(responseEvent.Response, false), out found))
                    {
                        if (_logger.IsDebugEnabled) _logger.Debug("Found a matching dialog.");

                        ctx.SetDialog(found);
                    }
                    else
                    {
                        if (_logger.IsDebugEnabled) _logger.Debug("A matching dialog could not be 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...");

                /*try dialog as processor*/
                SipAbstractDialog dialog;
                if (_dialogTable.TryGetValue(GetDialogId(responseEvent.Response, false), out dialog))
                {
                    if (_logger.IsTraceEnabled) _logger.Trace("Found a matching dialog. Setting it as the responseProcessor.");

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

            try
            {
                sipResponseProcessor.ProcessResponse(responseEvent);
            }
            catch (Exception err)
            {
                _logger.ErrorException("Response failed.", err);
                throw;
            }
        }
Exemplo n.º 32
0
        /// <summary>
        /// determines the send to
        /// </summary>
        /// <remarks>in case via header is missing returns the socket remote endpoint</remarks>
        private static IPEndPoint DetermineSendTo(SipContext context)
        {
            var response = context.Response;

            return(DetermineSendTo(response));
        }
Exemplo n.º 33
0
        private void OnRequestReceived(SipRequest request, SipContext context)
        {
            // last thread should signal main test

            lock (_failedThreads)
            {
                Interlocked.Decrement(ref _currentThreadCount);
                Console.WriteLine(request.CSeq.Sequence + " done, left: " + _currentThreadCount);

                if (_currentThreadCount == 0)
                    _threadsDoneEvent.Set();
            }
        }
Exemplo n.º 34
0
        private SipContext CreateSipContext(SipMessage message, Datagram datagram)
        {
            var request = message as SipRequest;
            var response = message as SipResponse;
            
            if (request != null)
            {
                _logger.Debug("Request Received '" + request.RequestLine.Method + " " + request.RequestLine.Uri.FormatToString() + "' from " +
                              datagram.RemoteEndPoint);
            }
            else
            {
                _logger.Debug("Response Received '" + response.StatusLine.StatusCode + " " + response.StatusLine.ReasonPhrase + "' from " +
                             datagram.RemoteEndPoint);
            }
               
            var c = new SipContext();

            _logger.Trace("Parse on parser context completed.");

            c.Request = request;
            c.Response = response;
            c.RemoteEndPoint = datagram.RemoteEndPoint;
            c.LocalEndPoint = datagram.LocalEndPoint;

            return c;
        }
Exemplo n.º 35
0
 private void OnRequestReceived(SipRequest request, SipContext context)
 {
     _requestReceived.Set();
 }
Exemplo n.º 36
0
 protected abstract void OnTestClientUaReceive(SipContext sipContext);
Exemplo n.º 37
0
 private void OnRecievedResponse(SipResponse sipResponse, SipContext sipContext)
 {
 }
Exemplo n.º 38
0
 protected override void OnTestClientUaReceive(SipContext sipContext)
 {
 }