コード例 #1
0
 protected override void OnTestClientUaReceive(SipContext sipContext)
 {
     if (sipContext.Request.RequestLine.Method == SipMethods.Invite)
     {
         _waitingforInviteReceived.Set();
     }
 }
コード例 #2
0
 protected override void OnTestClientUaReceive(SipContext sipContext)
 {
     if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x180_Ringing)
     {
         if (_receivedRingingResponse == null) _receivedRingingResponse = sipContext.Response;
     }
 }
コード例 #3
0
ファイル: SipContextSource.cs プロジェクト: goupviet/Hallo
        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);
 }
コード例 #5
0
 protected override void When()
 {
     /*create ringing response*/
     var c = new SipContext();
     _response = CreateRingingResponse();
     c.Response = _response;
     _contextSource.FireNewContextReceivedEvent(c);
 }
コード例 #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);
 }
コード例 #9
0
 private void OnNewContextReceived(SipContext context)
 {
     if (context.Request != null)
     {
         OnIncomingRequestContext(context);
     }
     else
     {
         OnIncomingResponseContext(context);
     }
 }
コード例 #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();
            }
        }
コード例 #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();
     }
 }
コード例 #12
0
ファイル: FakeNetwork.cs プロジェクト: HNeukermans/Hallo
        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;
        }
コード例 #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();
             }
         }
     }
 }
コード例 #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);
        }
コード例 #15
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();
     }
     if (sipContext.Response.StatusLine.ResponseCode == SipResponseCodes.x200_Ok &&
         sipContext.Response.CSeq.Command == SipMethods.Bye)
     {
         _receivedOkByeResponse = sipContext.Response;
         _waitForByeReceived.Set();
     }
 }
コード例 #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();
            }
        }
コード例 #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;
        }
コード例 #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;
            }
        }
コード例 #19
0
 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();
         }
     }
 }
コード例 #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);
        }
コード例 #21
0
 public void ProcessResponse(SipResponse sipResponse, SipContext context)
 {
     lock (_locker) Responses.Add(sipResponse);
     _onRecievedResponse(sipResponse, context);
 }
コード例 #22
0
ファイル: SipProvider.cs プロジェクト: HNeukermans/Hallo
        /// <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;
            }
        }
コード例 #23
0
ファイル: SipProvider.cs プロジェクト: HNeukermans/Hallo
        /// <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);
        }
コード例 #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);
                }
            }
        }
コード例 #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;
            }
        }
コード例 #26
0
ファイル: SipProvider.cs プロジェクト: HNeukermans/Hallo
 private void OnNewContextReceived(SipContext context)
 {
     if (context.Request != null)
     {
         OnIncomingRequestContext(context);
     }
     else
     {
         OnIncomingResponseContext(context);
     }
 }
コード例 #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});
     }
 }
コード例 #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);
        }
コード例 #29
0
ファイル: SipProvider.cs プロジェクト: HNeukermans/Hallo
        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);
                }
            }
        }
コード例 #30
0
 public void ProcessRequest(SipRequest sipRequest, SipContext context)
 {
     lock (_locker) Requests.Add(sipRequest);
     _onRecievedRequest(sipRequest, context);
 }
コード例 #31
0
ファイル: SipProvider.cs プロジェクト: HNeukermans/Hallo
        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;
            }
        }
コード例 #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));
        }
コード例 #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();
            }
        }
コード例 #34
0
ファイル: SipContextSource.cs プロジェクト: HNeukermans/Hallo
        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;
        }
コード例 #35
0
 private void OnRequestReceived(SipRequest request, SipContext context)
 {
     _requestReceived.Set();
 }
コード例 #36
0
 protected abstract void OnTestClientUaReceive(SipContext sipContext);
コード例 #37
0
 private void OnRecievedResponse(SipResponse sipResponse, SipContext sipContext)
 {
 }
コード例 #38
0
ファイル: When_Idle.cs プロジェクト: HNeukermans/Hallo
 protected override void OnTestClientUaReceive(SipContext sipContext)
 {
 }