Code Snippet
public class OutboundCallsHost : IHostedSpeechApplication
{
private IApplicationHost _host;
public OutboundCallsHost()
{
}
public void Start(IApplicationHost host)
{
_host = host;
_host.TelephonySession.OpenCompleted += TelephonySession_OpenCompleted;
_host.TelephonySession.Closing += TelephonySession_Closing;
// Put your telephony number in here. This can be extracted from host.Url.Query, if that is how you'll be passing it in
_host.TelephonySession.OpenAsync("123456789");
}
void TelephonySession_OpenCompleted(object sender, AsyncCompletedEventArgs e)
{
if (e.Error != null)
{
_host.OnCompleted();
}
}
void TelephonySession_Closing(object sender, ClosingEventArgs e)
{
_host.OnCompleted();
}
public void Stop(bool immediate)
{
_host.OnCompleted();
}
public void OnUnhandledException(Exception exception)
{
if (exception != null)
{
_host.TelephonySession.LoggingManager.LogApplicationError(100, "An unexpected exception occurred: {0}", exception.Message);
}
else
{
_host.TelephonySession.LoggingManager.LogApplicationError(100,
"An unknown exception occurred: {0}", System.Environment.StackTrace);
}
_host.OnCompleted();
}
}