|
TelephonyServerNewCall Event |
Fires when there is a new inbound call sent from the Voice Elements Server.
Namespace:
VoiceElements.Client
Assembly:
VoiceElementsClient (in VoiceElementsClient.dll) Version: 8.6.1.1
Syntax public event NewCall NewCall
Public Event NewCall As NewCall
public:
event NewCall^ NewCall {
void add (NewCall^ value);
void remove (NewCall^ value);
}
member NewCall : IEvent<NewCall,
NewCallEventArgs>
Return Value
Type:
This event comes along with a
New Call Argument Object, which contains a reference to the
Channel Resource that has been assigned for the duration of the new call. You will use this object along with
the
Voice Resource for all
Plays,
Get Responses and other voice functions. To access the Voice Resource, you will find a reference in the
Voice Resource Property of the Channel Resource in the NewCallEventArgs.
Remarks You Must Register DNIS's to Receive Calls
Before the Voice Elements Server that handles telephony resources will send new calls to your application and fire this event, you must
Register DNIS(s)
with the Voice Elements Server. If this is not done, the server will not raise New Call Events. For more information about DNIS, see
What's a DNIS?Threading and Best Practices
Voice Elements handles creation of a thread behind the scenes before calling this event. You can spend the entire length of the call in this event, therefore there is no need to quickly exit.
The simplest approach to designing a simple inbound application is to create a inbound script class and call that class from this event.
Define your New Call Event in your Start Up Code
Put something like this in your startup code:
s_TelephonyServer.NewCall += new VoiceElements.Client.NewCall(s_TelephonyServer_NewCall); Determine the entry point of your application and
decide where you would like to begin receiving these events. You may make this before or after you
Register DNIS(s), since the server will
not even try to raise events until the registration is done.
Subscribe to Disconnected Events
You should always subscribe to
Disconnect Events (aka Hang Ups) immediately upon getting a New Call event. Always do this unless you explicitly have a reason not to do so.
The following code line will do this subscription (C#):
e.ChannelResource.Disconnected += new Disconnected(ChannelResource_Disconnected); Determine the entry point of your application and
decide where you would like to begin receiving these events. You may make this before or after you
Register DNIS(s), since the server will
not even try to raise events until the registration is done.
Examples
The example below shows a chunk of code that executes when the event arrives. Notice that the sample immediately begins gathering information from the ChannelResource object reference
passed in the NewCallEventArgs object "e". The code then Answers the call, creates and instance of an IVR application class and executes an RunScript method.
These are created by you and this model is recommended as the simplest way to encapsulate your IVR script.
static void s_TelephonyServer_NewCall(object sender, VoiceElements.Client.NewCallEventArgs e)
{
try
{
Log.Write("NewCall Arrival! DNIS: {0} ANI: {1} Caller ID Name: {2}", e.ChannelResource.Dnis, e.ChannelResource.Ani, e.ChannelResource.CallerIdName);
e.ChannelResource.Disconnected += new Disconnected(ChannelResource_Disconnected);
Log.Write("Answering...");
e.ChannelResource.Answer();
Log.Write("Calling My IVR Application");
MyIVRApplication ivrApp = new MyIVRApplication(s_TelephonyServer, e.ChannelResource, Log);
ivrApp1.RunScript();
}
catch (HangupException)
{
Log.Write("The Caller Hung Up.");
}
catch (Exception ex)
{
Log.WriteException(ex, "IvrApplication::NewCall");
}
finally
{
try
{
try { e.ChannelResource.Disconnected -= new Disconnected(ChannelResource_Disconnected); }
catch { }
try { e.ChannelResource.Disconnect(); }
catch { }
try { e.ChannelResource.Dispose(); }
catch { }
Log.Write("Call complete.");
}
catch(Exception ex)
{
Log.WriteException(ex, "Error in finally block");
}
}
}
Private Shared Sub s_TelephonyServer_NewCall(ByVal sender As Object, ByVal e As VoiceElements.Client.NewCallEventArgs)
Try
Log.Write("NewCall Arrival! DNIS: {0} ANI: {1} Caller ID Name: {2}", e.ChannelResource.Dnis, e.ChannelResource.Ani, e.ChannelResource.CallerIdName)
AddHandler e.ChannelResource.Disconnected, AddressOf ChannelResource_Disconnected
Log.Write("Answering...")
e.ChannelResource.Answer()
Log.Write("Calling My IVR Application")
Dim ivrApp As New MyIVRApplication(s_TelephonyServer, e.ChannelResource, Log)
ivrApp1.RunScript()
Catch generatedExceptionName As HangupException
Log.Write("The Caller Hung Up.")
Catch ex As Exception
Log.WriteException(ex, "IvrApplication::NewCall")
Finally
Try
Try
RemoveHandler e.ChannelResource.Disconnected, AddressOf ChannelResource_Disconnected
Catch
End Try
Try
e.ChannelResource.Disconnect()
Catch
End Try
Try
e.ChannelResource.Dispose()
Catch
End Try
Log.Write("Call complete.")
Catch ex As Exception
Log.WriteException(ex, "Error in finally block")
End Try
End Try
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also