Common user scenarios and source code examples 593
Call received notification
The following C# code fragment shows a condensed version of the source code provided with the
ConsoleCallMonitor sample application that is shipped with the CTI Developer Toolkit.
static void Main()
{
DeviceManager dm = DeviceManager.Instance;
string pbxIpAddress = "10.1.1.10";
string server = "the-CCM-server-IP-address-here";
string username = "your-username-here";
string password = "your-password-here";
Voice extension;
if (!dm.Connect(server, 5024, username, password))
{
Console.WriteLine("Uable to connect to server");
return;
}
extension = dm.GetDevice("1100", pbxIpAddress, DeviceType.Extension) as Voice;
if (extension == null)
{
Console.WriteLine("Unable to retrieve extension device");
return;
}
if (!extension.SetMonitor())
{
Console.WriteLine("Unable to monitor extension");
return;
}
device.CallInfoReceived += CallInfoReceivedHandler;
Console.WriteLine("Listening for calls on extension 1100");
Console.WriteLine("Press any key to end application.");
while (!Console.KeyAvailable) ;
dm.ReleaseAllDevices();
dm.Disconnect();
Console.WriteLine("Exit application");
}
static void CallInfoReceivedHandler(object sender, CallInfoReceivedEventArgs e)
{
Console.WriteLine("-----------------------------------------------");
Console.WriteLine("Call Info Received:");
Console.WriteLine(" Caller Name : " + e.Info.CallerName);
Console.WriteLine(" Caller Number : " + e.Info.CallerNumber);
Console.WriteLine(" DNIS : " + e.Info.DNIS);
Console.WriteLine(" Collected Digits : " + e.Info.CollectedDigits);
}