DMCC CSharp Telecommuter Sample Code Documentation
DMCC CSharp Telecommuter Sample Code Documentation
Abstract
The TeleCommuter application is a Device, Media and Call Control (DMCC) sample
application which demonstrates usage of DMCC XML messages for performing various
telephony services. This application sets up a “Telecommuter Number” for a given extension
by using DMCC XML messages supported by Avaya Application Enablement Services (AE
Services).
The application was built and tested using the following configuration:
• Avaya Communication Manager 4.0.
• Avaya Application Enablement Services 4.0
• PC running Microsoft XP Professional Version 2002 Service Pack 2
• Microsoft .NET Framework Version 2.0
• Microsoft Visual C# 2005 Version 8.0.50727.42
Communication Manager
NOTE:
• DMCC.server_port and DMCC.secure fields are interdependent, i.e., if
DMCC.server_port field is set to 4721, then DMCC.secure must be set to false and if
DMCC.server_port field is set to 4722, then DMCC.secure must be set to true.
The DMCC.server_port field represents the access port which will be used by the application to
communicate with the AE Services server. It can take one of two values: i.e. 4721 for secure
connection and 4722 for non secure connection. Note that 4721 and 4722 represent the default
ports on an AE Services server, and these can be changed via AE Services OA&M. Note further
that only the secure port is enabled by default, and if the non-secure port is going to be used, it
must be enable via AE Services OA&M. Login to AE Services OA&M (http://<ip-address-of-
AE Services server>:8080/MVAP and go to “CTI OAM Administration > Network
Configuration > Ports”. Enable required DMCC server port, and then restart the MVAP
application using “CTI OAM Administration > Maintenance > .Service Controller > Restart AE
Server”. Here is a snapshot showing how to configure DMCC server ports.
When the application starts, a console window will be displayed informing the user about the
start up process. The application requests a new application session with the AE Services server,
creates a deviceID for the primary extension, sets up a monitor to receive required events and
registers the deviceID along with the telecommuter number. The application now waits for
incoming calls on the primary extension.
When the primary extension is called, an event indicating incoming call is received by both the
extensions; i.e. the dialed extension (which is being handled by the telecommuter sample code
and not the physical primary station) and the telecommuter number. The call can then be
answered at the telecommuter number and appropriate events indicating changes in the call state
will be displayed in the application console. The audio path will be between the calling telephone
and the phone rung by the telecommuter number (unless a feature such as call pickup, bridging
or similar service is utilized).
• XMLParser.cs - Contains XMLParser class. This class provides the functionality for
handling all XML messages that are exchanged between the application and the AE
Services server. Some methods from this class like StartApplicationSession,
MonitorStart are required for initialization and are used only once. These methods
format the required XML request using XMLFormatter class, then send the request to the
server over a TCP connection and wait for the response from the server. There are two
different ways, synchronous and asynchronous, in which responses are handled by the
XMLParser class. During initialization, after sending the requests, application blocks till a
response is received. These are synchronous responses and ensure that session
initialization is done correctly before application proceeds. However, after initialization,
all the responses and events are received asynchronously. These are collected using a
separate thread. There are two methods which start a new working thread. These are
StartAutoKeepAlive, which starts a thread for periodically sending keep alive request
and Run()which starts a thread for receiving all the asynchronous events. On receiving
these events, this function calls the event handler and passes the control to the
TeleCommuter class for handling the event
• XMLHandler.cs - Contains the XMLHandler class. This class provides the functionality
for sending and reading the XML messages between the application and the AE Services
server. It accomplishes it with the help of the two functions viz. sendrequest() and
readXMLMessage(). The readXMLMessage()function is used to read the various
responses received from the AE Services server and parse the XML data contained in it.
The XML message is then used for further processing by the XMLParser class. The
sendrequest() constructs the XML message according to CSTA-ECMA 323 standard
format and sends over the writer stream.
• XMLFormatter.cs - Contains the XMLFormatter class. Each function from this class
provides the exact XML request required by the application to communicate with the AE
Services server. These methods take parameters associated with the request and format
the XML request string. This class is used by XMLParser class for formatting various
XML requests.
• SocketHandler.cs - Contains the SocketHandler class. This class creates TCP socket
and attaches stream reader and writer to it. This reader and writer will be used to read
response data and write request data respectively. The openSocket() function gets
invoked in the XMLParser class when the application starts. For non-secure port this
class uses a NetowrkStream object. In case of secure port, SslStream object is used and
the application is authenticated with the server.
• EventArgs.cs - Contains the list of classes which are used for passing event information
when an event handler is invoked. There is one class for each event handled by the
application e.g. LampModeEventArgs class holds the information for LampModeEvent.
Like all XML API based applications, the TeleCommuter application follows this basic flow.
5.2.1. Initialization
When the application starts, TeleCommuter class initiates a new instance of XMLParser class
and invokes functions from this class to setup an application session. It calls Start function for
this and here is the snapshot of the code:
AddEventHandlers();
string host = (string)propertyList[DMCC_SERVER_IP];
int port = Int32.Parse((string)propertyList[DMCC_SERVER_PORT]);
string username = (string)propertyList[DMCC_USERNAME];
string password = (string)propertyList[DMCC_PASSWORD];
string protocol_version = (string)propertyList[DMCC_PROTOCOL_VERSION];
string secure = (string)propertyList[DMCC_SECURE];
if (SessionID == null)
{
return;
}
Console.WriteLine("Device created.");
if (MonitorRefID == null)
{
return;
}
Console.WriteLine("Terminal Registered.");
Run();
}
XMLFormatter class provides the XML request format for all XML requests used by this
application. Here is the snapshot for the RegisterTerminalRequest:
return getRegisterTerminalRequest;
}
Note that as a part of the RegisterTerminalRequest, the application provides the telecommuter
number.
The TeleCommuter application is sent these events by the AE Services server based on the
monitor that is has requested on the device and displays information regarding these events on
the console, as and when it receives them. Developers can enhance the routine handlers to
implement their own telephony logic based on the application requirements.
The application gets to know details about the events received by looking up the event structure
and the following section gives details about two sample events.
The ring pattern is supplied in the “RingerStatusEvent” event structure. Since this message is
an asynchronous message sent by AE Services server, there is a MonitorCrossRefID which is
used for correlating the message to the MonitorStart.
if ((RingPattern)args.RingPattern == RingPattern.RingerOff)
{
Console.WriteLine("The ringer is off.");
}
else
{
/* There are a number of different ringing patterns that can indicate
* that a call has been offered to the destination staition.
* Print out the pattern and expect that an interested user
* will investigate more throughly.
*/
Console.WriteLine("The ringer is ringing in pattern:" +
(RingPattern)args.RingPattern);
}
The identifier of the lamp that has changed, the lamp’s color and the lamp’s mode is supplied in
the LampModeEvent event structure. By detecting the state of the lamp with the lamp mode
constants, the application infers the call status. For example, if the lamp mode constant is “7”
and the lamp color is “3”, it implies a green flashing lamp and hence the call status is an
incoming call.
The display contents are supplied in the “DisplayUpdatedEvent” event structure. This
application currently displays contents on the screen. Here is a snapshot for
DisplayUpdatedEvent handler routine.
if(args.Message != null)
Console.WriteLine("Display update event: " + args.Message);
When initialization is complete and application is waiting for events, the application will not
send any messages to the AE Services server (by its design – while other applications may
intermittently send messages they too need to implement a keep-alive handshake). Unless the
application sends keep alive messages, the AE Services server will expire the session at the end
of the session duration interval. To avoid this condition, the application must to send keep-alive
signals to the server at periodic intervals to keep the application session active.
6. Support
Available at http://www.avaya.com/support
7. Conclusion
The TeleCommuter application is a Device, Media and Call Control (DMCC) sample application
which demonstrates usage of DMCC XML APIs for performing various Telephony services. An
overall view of the sample code as well as usage instructions has been presented in this
document.
8. Additional References
8.1. Documentation
For additional information regarding DMCC XML API programming, refer to the following
document:
• Avaya Application Enablement Services Device, Media and Call Control API XML
Programmer Guide R3.1.1 Document ID 02-300358, Issue 2.2, May 2006, available at
http://www.avaya.com/devconnect or http://www.avaya.com/support
For additional information regarding administration of Application Enablement Services refer to:
• Avaya MultiVantage Application Enablement Services Administration and Maintenance
Guide Release 3.1.2, Document ID 02-300357, Issue 4, September 2006, available at
http://www.avaya.com/devconnect or http://www.avaya.com/support
• Avaya MultiVantage Application Enablement Services Administration and Maintenance
Guide Release 4.0, Document ID 02-300357, Issue 6, February 2007, available at
http://www.avaya.com/devconnect or http://www.avaya.com/support
CM Communication Manager
Please e-mail any questions or comments pertaining to these Application Notes along with the
full title name and filename, located in the lower right corner, directly to the Avaya DevConnect
Program at devconnect@avaya.com.