我正在尝试构建一个UCMA独立的出站拨号器。遗憾的是,我无法找到有关如何连接到SIP或如何开始配置的大量信息。我有一个GetOnSIP,并希望将它与我的应用程序联系起来。任何帮助将不胜感激!
由于
//设置我的应用程序
internal void Start()
{
_applicationId = ConfigurationManager.AppSettings["applicationId"];
_recipientSipUri = ConfigurationManager.AppSettings["recipientSipUri"];
//string urisToDialString = ConfigurationManager.AppSettings["numbersToDial"];
_urisToDial.Add("phone number goes here");
ServerPlatformSettings platformSettingsObj = new ServerPlatformSettings(_applicationId, Dns.GetHostEntry("localhost").HostName,
5060, string.Empty /* empty string for the GRUU */);
Utils.WriteDebug("Endpoint: " + platformSettingsObj.Localhost);
_platform = new CollaborationPlatform(platformSettingsObj);
_platform.AllowedAuthenticationProtocol = SipAuthenticationProtocols.None;
try
{
_platform.BeginStartup(ar =>
{
try
{
_platform.EndStartup(ar);
Console.WriteLine("Platform started.");
StartEndpoint();
Console.WriteLine("Platform Endpoint Initiated.");
CallSession sessionObj = new CallSession(_urisToDial.First(), _endpoint);
sessionObj.InitiateCall();
}
catch (RealTimeException ex)
{
Console.WriteLine(ex);
}
}, null);
}
catch (InvalidOperationException ex)
{
Console.WriteLine(ex);
}
}
private void StartEndpoint()
{
// Create a placeholder URI for the endpoint.
ApplicationEndpointSettings endpointSettings =
new ApplicationEndpointSettings("sip:default@" +
Dns.GetHostEntry("localhost").HostName);
// Make this a default routing endpoint, so that
// all requests sent to the listening port on this IP,
// regardless of To URI, will come to the endpoint.
endpointSettings.IsDefaultRoutingEndpoint = true;
// Create a new endpoint and register for AV calls.
_endpoint = new ApplicationEndpoint(_platform, endpointSettings);
_endpoint.RegisterForIncomingCall<AudioVideoCall>(OnCallReceived);
try
{
_endpoint.BeginEstablish(ar =>
{
try
{
_endpoint.EndEstablish(ar);
Console.WriteLine("Endpoint started.");
}
catch (RealTimeException ex)
{
Console.WriteLine(ex);
}
}, null);
}
catch (InvalidOperationException ex)
{
Console.WriteLine(ex);
}
}
public CallSession(string number,ApplicationEndpoint endpointObj) { //设置应发送INVITE的主机和端口 //我猜这是sbc ip的所在 ConnectionContext connectionContextObj = new ConnectionContext(&#34; 192.168.0.56&#34;,5060);
optionsObj.ConnectionContext = connectionContextObj;
//configure this to use udp
_phoneNumber = number;
_endpoint = endpointObj;
}
public bool InitiateCall()
{
bool isInitiated = true;
try
{
Utils.WriteDebug("About to Initiate a phone Call");
Conversation convObj = new Conversation(_endpoint);
AudioVideoCall avcallObj = new AudioVideoCall(convObj);
// Establish the call using the options we created
//avcall.BeginEstablish("sip:test@test.greenl.ee", optionsObj,
avcallObj.BeginEstablish("tel:+" + _phoneNumber, optionsObj,
ar =>
{
try
{
avcallObj.EndEstablish(ar);
Console.WriteLine("The call with Local Participant: " + avcallObj.Conversation.LocalParticipant + " and Remote Participant: " + avcallObj.RemoteEndpoint.Participant + " is now in the established state.");
}
catch (RealTimeException ex)
{
isInitiated = false;
Utils.LogError(ex);
}
},
null);
}
catch (InvalidOperationException ex)
{
isInitiated = false;
Utils.LogError(ex);
}
return isInitiated;
}