コード例 #1
0
        public void Progress(SIPResponseStatusCodesEnum progressStatus, string reasonPhrase, string[] customHeaders,
                             string progressContentType, string progressBody)
        {
            try
            {
                if (!IsUASAnswered)
                {
                    if ((int)progressStatus >= 200)
                    {
                    }
                    else
                    {
                        UASStateChanged?.Invoke(this, progressStatus, reasonPhrase);

                        if (m_uasTransaction.TransactionState == SIPTransactionStatesEnum.Proceeding)
                        {
                        }
                        else
                        {
                            SIPResponse uasProgressResponse =
                                SIPTransport.GetResponse(m_uasTransaction.TransactionRequest, progressStatus,
                                                         reasonPhrase);
                            m_uasTransaction.SendInformationalResponse(uasProgressResponse);

                            SIPResponse uacProgressResponse =
                                SIPTransport.GetResponse(m_uacTransaction.TransactionRequest, progressStatus,
                                                         reasonPhrase);
                            if (!progressBody.IsNullOrBlank())
                            {
                                uacProgressResponse.Body = progressBody;
                                uacProgressResponse.Header.ContentType = progressContentType;
                            }

                            if (customHeaders != null && customHeaders.Length > 0)
                            {
                                foreach (string header in customHeaders)
                                {
                                    uacProgressResponse.Header.UnknownHeaders.Add(header);
                                }
                            }

                            m_uacTransaction.GotResponse(m_blackhole, m_blackhole, uacProgressResponse);
                            CallRinging(this, uacProgressResponse);
                        }
                    }
                }
                else
                {
                    logger.Warn("B2BUserAgent Progress fired on already answered call.");
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception B2BUserAgent Progress. " + excp.Message);
            }
        }
コード例 #2
0
        public void Progress(SIPResponseStatusCodesEnum progressStatus, string reasonPhrase, string[] customHeaders, string progressContentType, string progressBody)
        {
            try
            {
                if (!IsUASAnswered)
                {
                    if ((int)progressStatus >= 200)
                    {
                        Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "B2BUA call was passed an invalid response status of " + (int)progressStatus + ", ignoring.", m_uacOwner));
                    }
                    else
                    {
                        if (UASStateChanged != null)
                        {
                            UASStateChanged(this, progressStatus, reasonPhrase);
                        }

                        if (m_uasTransaction.TransactionState == SIPTransactionStatesEnum.Proceeding)
                        {
                            Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "B2BUA call ignoring progress response with status of " + (int)progressStatus + " as already in " + m_uasTransaction.TransactionState + ".", m_uacOwner));
                        }
                        else
                        {
                            Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "B2BUA call progressing with " + progressStatus + ".", m_uacOwner));
                            SIPResponse uasProgressResponse = SIPTransport.GetResponse(m_uasTransaction.TransactionRequest, progressStatus, reasonPhrase);
                            m_uasTransaction.SendProvisionalResponse(uasProgressResponse);

                            SIPResponse uacProgressResponse = SIPTransport.GetResponse(m_uacTransaction.TransactionRequest, progressStatus, reasonPhrase);
                            if (!progressBody.IsNullOrBlank())
                            {
                                uacProgressResponse.Body = progressBody;
                                uacProgressResponse.Header.ContentType = progressContentType;
                            }
                            if (customHeaders != null && customHeaders.Length > 0)
                            {
                                foreach (string header in customHeaders)
                                {
                                    uacProgressResponse.Header.UnknownHeaders.Add(header);
                                }
                            }
                            m_uacTransaction.GotResponse(m_blackhole, m_blackhole, uacProgressResponse);
                            CallRinging((ISIPClientUserAgent)this, uacProgressResponse);
                        }
                    }
                }
                else
                {
                    logger.LogWarning("B2BUserAgent Progress fired on already answered call.");
                }
            }
            catch (Exception excp)
            {
                logger.LogError("Exception B2BUserAgent Progress. " + excp.Message);
            }
        }
コード例 #3
0
        public async Task UacTxCheckRemoteSocketProxyReceivedUnitTestUnitTest()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            SIPEndPoint dummyEP = new SIPEndPoint(new IPEndPoint(IPAddress.Any, 5060));

            string inviteReqStr =
                @"INVITE sip:[email protected]:12014 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:1234;branch=z9hG4bK5f37455955ca433a902f8fea0ce2dc27
To: <sip:[email protected]:12014>
From: <sip:[email protected]>;tag=2062917371
Call-ID: 8ae45c15425040179a4285d774ccbaf6
CSeq: 1 INVITE
Contact: <sip:127.0.0.1:1234>
Max-Forwards: 70
User-Agent: unittest
Content-Length: 5
Content-Type: application/sdp

dummy";
            var        sipReqBuffer = SIPMessageBuffer.ParseSIPMessage(inviteReqStr, dummyEP, dummyEP);
            SIPRequest inviteReq    = SIPRequest.ParseSIPRequest(sipReqBuffer);

            string okRespStr =
                @"SIP/2.0 200 OK
Via: SIP/2.0/UDP 127.0.0.1:1234;branch=z9hG4bK5f37455955ca433a902f8fea0ce2dc27;rport=12013
To: <sip:[email protected]:12014>
From: <sip:[email protected]>;tag=2062917371
Call-ID: 8ae45c15425040179a4285d774ccbaf6
Contact: <sip:127.0.0.1:1234>
CSeq: 1 INVITE
Content-Length: 5
Content-Type: application/sdp
Proxy-ReceivedFrom: udp:192.168.0.50:5080

dummy";

            var         sipRespBuffer = SIPMessageBuffer.ParseSIPMessage(okRespStr, dummyEP, dummyEP);
            SIPResponse okResponse    = SIPResponse.ParseSIPResponse(sipRespBuffer);

            SIPTransport transport = new SIPTransport();

            transport.AddSIPChannel(new MockSIPChannel(dummyEP.GetIPEndPoint()));

            UACInviteTransaction uacTx = new UACInviteTransaction(transport, inviteReq, null);
            await uacTx.GotResponse(dummyEP, dummyEP, okResponse);

            var dialogue = new SIPDialogue(uacTx);

            Assert.NotNull(dialogue);
            Assert.Equal(SIPURI.ParseSIPURI("sip:127.0.0.1:1234"), dialogue.RemoteTarget);
            Assert.Equal(SIPEndPoint.ParseSIPEndPoint("udp:192.168.0.50:5080"), dialogue.RemoteSIPEndPoint);

            logger.LogDebug("---------------------------------------------------");
        }