// Retrieve telephony device list from telephony controller.
var deviceList = cwic.TelephonyController.telephonyDevices;
var deskphone;
// In this example we'll take first deskphone from telephony device list we encounter
for(var index = 0; index < deviceList.length; ++index)
{
if(deviceList[index].controlMode = "Deskphone")
{
deskphone = deviceList[index];
break;
}
}
Connecting DeskPhone with CUCM is done through DeskPhone.connect method. Generally, device can be
connected to CUCM only from single client/machine. Thus, if connecting same device to CUCM from another client/machine,
CUCM will reject connection attempt. However, if connecting device with forced registration, connection attempt will
be accepted by CUCM. In the snippet below force registration will be used to connect softphone with CUCM:
var forceRegistration = true;
deskphone.connect(true);
After this DeskPhone device will be successfully connected with CUCM. For information on how to track device's connection state with CUCM or if connection fails for some reason please see Handle CUCM Connection State Change tutorial.
Change Active Line
With DeskPhone device, if it has more then one telephony line it can use, choice can be made which one will be used. List of available telephony lines can be retrieved, but only once deskphone has been connected with CUCM. New active line can be selected through DeskPhone.selectLine method, as it is shown in the snippet bellow:
// For the sake of this example we'll assume that we have 3 available lines [1111, 1112, 1113]
var telephonyLines = deskphone.lineDirectoryNumbers;
// We'll select line 1112.
var telephonyLineToSelect = telephonyLines[1]
deskphone.selectLine(telephonyLineToSelect);