InitiateCall() public method

Initiates a Google Voice callback by sending 3 HTTP requests and then waiting for the incoming SIP call.
public InitiateCall ( string emailAddress, string password, string forwardingNumber, string destinationNumber, string fromUserRegexMatch, int phoneType, int waitForCallbackTimeout, string contentType, string body ) : SIPDialogue
emailAddress string The Google Voice email address to login with.
password string The Google Voice password to login with.
forwardingNumber string The number to request Google Voice to do the intial callback on.
destinationNumber string The number to request Google Voice to dial out on. This is what Google will attempt to /// call once the callback on the forwardingNumber is answered.
fromUserRegexMatch string
phoneType int
waitForCallbackTimeout int
contentType string The content type of the SIP call into sipsorcery that created the Google Voice call. It is /// what will be sent in the Ok response to the initial incoming callback.
body string The content of the SIP call into sipsorcery that created the Google Voice call. It is /// what will be sent in the Ok response to the initial incoming callback.
return SIPSorcery.SIP.SIPDialogue
コード例 #1
0
        public void Call(SIPCallDescriptor descriptor)
        {
            try
            {
                CallDescriptor = descriptor;
                SIPURI destinationURI = SIPURI.ParseSIPURIRelaxed(descriptor.Uri);

                bool       wasSDPMangled = false;
                IPEndPoint sdpEndPoint   = null;
                if (descriptor.MangleIPAddress != null)
                {
                    sdpEndPoint = SDP.GetSDPRTPEndPoint(descriptor.Content);
                    if (sdpEndPoint != null)
                    {
                        descriptor.Content = SIPPacketMangler.MangleSDP(descriptor.Content, descriptor.MangleIPAddress.ToString(), out wasSDPMangled);
                    }
                }

                if (wasSDPMangled)
                {
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "SDP on Google Voice call had RTP socket mangled from " + sdpEndPoint.ToString() + " to " + descriptor.MangleIPAddress.ToString() + ":" + sdpEndPoint.Port + ".", Owner));
                }
                else if (sdpEndPoint != null)
                {
                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "SDP on Google Voice call could not be mangled, using original RTP socket of " + sdpEndPoint.ToString() + ".", Owner));
                }

                SIPDialogue = m_googleVoiceCall.InitiateCall(descriptor.Username, descriptor.Password, descriptor.CallbackNumber, destinationURI.User, descriptor.CallbackPattern, descriptor.CallbackPhoneType, MAX_CALLBACK_WAIT_TIME, descriptor.ContentType, descriptor.Content);

                if (SIPDialogue != null)
                {
                    CallAnswered(this, null);
                }
                else
                {
                    CallFailed(this, "Google Voice call failed.");
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception GoogleVoiceCallAgent Call. " + excp.Message);
                CallFailed(this, excp.Message);
            }
        }
コード例 #2
0
        public void GoogleVoiceCall(string emailAddress, string password, string forwardingNumber, string destinationNumber, string fromURIUserToMatch, int phoneType, int waitForCallbackTimeout)
        {
            try
            {
                DateTime startTime = DateTime.Now;

                ExtendScriptTimeout(DEFAULT_CREATECALL_RINGTIME);
                GoogleVoiceCall googleCall = new GoogleVoiceCall(m_sipTransport, m_callManager, m_dialPlanLogDelegate, m_username, m_adminMemberId, m_outboundProxySocket);
                m_dialPlanContext.CallCancelledByClient += googleCall.ClientCallTerminated;
                googleCall.CallProgress += m_dialPlanContext.CallProgress;

                string content = m_sipRequest.Body;
                IPAddress requestSDPAddress = (PublicIPAddress != null) ? PublicIPAddress : SIPPacketMangler.GetRequestIPAddress(m_sipRequest);

                IPEndPoint sdpEndPoint = (content.IsNullOrBlank()) ? null : SDP.GetSDPRTPEndPoint(content);
                if (sdpEndPoint != null)
                {
                    if (!IPSocket.IsPrivateAddress(sdpEndPoint.Address.ToString()))
                    {
                        Log("SDP on GoogleVoiceCall call had public IP not mangled, RTP socket " + sdpEndPoint.ToString() + ".");
                    }
                    else
                    {
                        bool wasSDPMangled = false;
                        if (requestSDPAddress != null)
                        {
                            if (sdpEndPoint != null)
                            {
                                content = SIPPacketMangler.MangleSDP(content, requestSDPAddress.ToString(), out wasSDPMangled);
                            }
                        }

                        if (wasSDPMangled)
                        {
                            Log("SDP on GoogleVoiceCall call had RTP socket mangled from " + sdpEndPoint.ToString() + " to " + requestSDPAddress.ToString() + ":" + sdpEndPoint.Port + ".");
                        }
                        else if (sdpEndPoint != null)
                        {
                            Log("SDP on GoogleVoiceCall could not be mangled, using original RTP socket of " + sdpEndPoint.ToString() + ".");
                        }
                    }
                }
                else
                {
                    Log("SDP RTP socket on GoogleVoiceCall call could not be determined.");
                }

                SIPDialogue answeredDialogue = googleCall.InitiateCall(emailAddress, password, forwardingNumber, destinationNumber, fromURIUserToMatch, phoneType, waitForCallbackTimeout, m_sipRequest.Header.ContentType, content);
                if (answeredDialogue != null)
                {
                    m_dialPlanContext.CallAnswered(SIPResponseStatusCodesEnum.Ok, null, null, null, answeredDialogue.ContentType, answeredDialogue.RemoteSDP, answeredDialogue, SIPDialogueTransferModesEnum.Default);

                    // Dial plan script stops once there is an answered call to bridge to or the client call is cancelled.
                    Log("Google Voice Call was successfully answered in " + DateTime.Now.Subtract(startTime).TotalSeconds.ToString("0.00") + "s.");
                    m_executingScript.StopExecution();
                }
            }
            catch (ThreadAbortException) { }
            catch (Exception excp)
            {
                Log("Exception on GoogleVoiceCall. " + excp.Message);
            }
        }