72sdk Dev Platform

download 72sdk Dev Platform

of 50

Transcript of 72sdk Dev Platform

  • Platform SDK 7.2

    Developers Guide

  • The information contained herein is proprietary and confidential and cannot be disclosed or duplicated without the prior written consent of Genesys Telecommunications Laboratories, Inc.Copyright 2006 Genesys Telecommunications Laboratories, Inc. All rights reserved.

    About GenesysGenesys Telecommunications Laboratories, Inc., a subsidiary of Alcatel, is 100% focused on software for call centers. Genesys recognizes that better interactions drive better business and build company reputations. Customer service solutions from Genesys deliver on this promise for Global 2000 enterprises, government organizations, and telecommunications service providers across 80 countries, directing more than 100 million customer interactions every day. Sophisticated routing and reporting across voice, e-mail, and Web channels ensure that customers are quickly connected to the best available resourcethe first time. Genesys offers solutions for customer service, help desks, order desks, collections, outbound telesales and service, and workforce management. Visit www.genesyslab.com for more information.Each product has its own documentation for online viewing at the Genesys Technical Support website or on the Documentation Library CD, which is available from Genesys upon request. For more information, contact your sales representative.

    NoticeAlthough reasonable effort is made to ensure that the information in this document is complete and accurate at the time of release, Genesys Telecommunications Laboratories, Inc., cannot assume responsibility for any existing errors. Changes and/or corrections to the information contained in this document may be incorporated in future versions.

    Your Responsibility for Your Systems SecurityYou are responsible for the security of your system. Product administration to prevent unauthorized use is your responsibility. Your system administrator should read all documents provided with this product to fully understand the features available that reduce your risk of incurring charges for unlicensed use of Genesys products.

    TrademarksGenesys, the Genesys logo, and T-Server are registered trademarks of Genesys Telecommunications Laboratories, Inc. All other trademarks and trade names referred to in this document are the property of other companies. The Crystal monospace font is used by permission of Software Renovation Corporation, www.SoftwareRenovation.com.

    Technical Support from VARsIf you have purchased support from a value-added reseller (VAR), please contact the VAR for technical support.

    Technical Support from GenesysIf you have purchased support directly from Genesys, please contact Genesys Technical Support at the following regional numbers:

    Prior to contacting technical support, please refer to the Genesys Technical Support Guide for complete contact information and procedures.

    Ordering and Licensing InformationComplete information on ordering and licensing Genesys products can be found in the Genesys 7 Licensing Guide.

    Released byGenesys Telecommunications Laboratories, Inc. www.genesyslab.comDocument Version: 72sdk_dev_platform_06-2006_v7.2.002.00

    Region Telephone E-Mail

    North and Latin America +888-369-5555 or +506-674-6767 [email protected]

    Europe, Middle East, and Africa +44 (0) 118 974 7002 [email protected]

    Asia Pacific +61 7 3368 6868 [email protected]

    Japan +81-3-5649-6871 [email protected]

  • Developers Guide 3

    Table of ContentsPreface ................................................................................................................... 5

    Intended Audience..................................................................................... 6Usage Guidelines ...................................................................................... 6Chapter Summaries................................................................................... 8Document Conventions ............................................................................. 8Related Resources.................................................................................. 10Making Comments on This Document .................................................... 11

    Chapter 1 About the Platform SDKs..................................................................... 13The Platform SDKs.................................................................................. 13

    Voice ................................................................................................... 13Open Media ........................................................................................ 14Outbound Contact............................................................................... 14Statistics.............................................................................................. 14Configuration ...................................................................................... 14

    Getting Started......................................................................................... 15Architecture of the Platform SDKs........................................................... 17Sending and Receiving Messages .......................................................... 17

    Requests and Responses................................................................... 18Unsolicited Events .............................................................................. 22

    Namespace Structure .............................................................................. 23Commons Namespaces ..................................................................... 23SDK-Specific Namespaces................................................................. 24

    Chapter 2 About the Code Examples................................................................... 25Setup for Development............................................................................ 25

    Source-Code Examples...................................................................... 25Required Third-Party Tools ................................................................. 26Environment Setup ............................................................................. 26Building the Examples ........................................................................ 27Configuration Data.............................................................................. 27

    Open Media Examples ............................................................................ 27Open Media Server Example.............................................................. 27Open Media Client Example ............................................................... 30

  • Table of Contents

    4 Platform SDK 7.2

    Voice Examples ....................................................................................... 36Statistics Example ................................................................................... 42

    Index ................................................................................................................. 47

  • Developers Guide 5

    PrefaceWelcome to the Platform SDK 7.2 Developers Guide. This document gives you the information you need to write programs that communicate directly with several of the servers in the Genesys Framework.This document is valid only for the 7.2 release of this product.

    Note: For versions of this document created for other releases of this product, please visit the Genesys Technical Support website, or request the Documentation Library CD, which you can order by e-mail from Genesys Order Management at [email protected].

    This preface contains these sections: z Intended Audience, page 6z Usage Guidelines, page 6z Chapter Summaries, page 8z Document Conventions, page 8z Related Resources, page 10z Making Comments on This Document, page 11The Platform SDKs are for developers requiring maximum flexibility. They provide this flexibility by giving you low-level access to the core functionality of the following Genesys servers: T-Servers Interaction Server Outbound Contact Server Stat Server Configuration ServerBy creating objects that communicate with these servers using their own protocols, you will be able to pass messages back and forth with any or all of them. Please note, however, that the added control you get from using the Platform SDKs may bring with it a longer development effort than you might need for software developed with SDKs that offer a higher level of abstraction, such as the Interaction SDK.

  • 6 Platform SDK 7.2

    Preface Intended Audience

    Intended AudienceThis document, primarily intended for software developers, assumes that you have a basic understanding of: Computer-telephony integration (CTI) concepts, processes, terminology,

    and applications. Network design and operation. Your own network configurations.You should also be familiar with: Software development using the C# or Java programming languages Genesys Framework architecture and functions

    Usage GuidelinesThe Genesys developer materials outlined in this document are intended to be used for the following purposes: Creation of contact-center agent desktop applications associated with

    Genesys software implementations. Server-side integration between Genesys software and third-party

    software. Creation of a specialized client application specific to customer needs.The Genesys software functions available for development are clearly documented. No undocumented functionality is to be utilized without Genesyss express written consent.The following Use Conditions apply in all cases for developers employing the Genesys developer materials outlined in this document:1. Possession of interface documentation does not imply a right to use by a

    third party. Genesys conditions for use, as outlined below or in the Genesys Developer Program Guide, must be met.

    2. This interface shall not be used unless the developer is a member in good standing of the Genesys Interacts program or has a valid Master Software License and Services Agreement with Genesys.

    3. A developer shall not be entitled to use any licenses granted hereunder unless the developers organization has met or obtained all prerequisite licensing and software as set out by Genesys.

    4. A developer shall not be entitled to use any licenses granted hereunder if the developers organization is delinquent in any payments or amounts owed to Genesys.

  • Developers Guide 7

    Preface Usage Guidelines

    5. A developer shall not use the Genesys developer materials outlined in this document for any general application development purposes that are not associated with the above-mentioned intended purposes for the use of the Genesys developer materials outlined in this document.

    6. A developer shall disclose the developer materials outlined in this document only to those employees who have a direct need to create, debug, and/or test one or more participant-specific objects and/or software files that access, communicate, or interoperate with the Genesys API.

    7. The developed works and Genesys software running in conjunction with one another (hereinafter referred to together as the integrated solutions) should not compromise data integrity. For example, if both the Genesys software and the integrated solutions can modify the same data, then modifications by either product must not circumvent the other products data integrity rules. In addition, the integration should not cause duplicate copies of data to exist in both participant and Genesys databases, unless it can be assured that data modifications propagate all copies within the time required by typical users.

    8. The integrated solutions shall not compromise data or application security, access, or visibility restrictions that are enforced by either the Genesys software or the developed works.

    9. The integrated solutions shall conform to design and implementation guidelines and restrictions described in the Genesys Developer Program Guide and Genesys software documentation. For example:a. The integration must use only published interfaces to access Genesys

    data.b. The integration shall not modify data in Genesys database tables

    directly using SQL.c. The integration shall not introduce database triggers or stored

    procedures that operate on Genesys database tables.Any schema extension to Genesys database tables must be carried out using Genesys Developer software through documented methods and features.The Genesys developer materials outlined in this document are not intended to be used for the creation of any product with functionality comparable to any Genesys products, including products similar or substantially similar to Genesyss current general-availability, beta, and announced products. Any attempt to use the Genesys developer materials outlined in this document or any Genesys Developer software contrary to this clause shall be deemed a material breach with immediate termination of this addendum, and Genesys shall be entitled to seek to protect its interests, including but not limited to, preliminary and permanent injunctive relief, as well as money damages.

  • 8 Platform SDK 7.2

    Preface Chapter Summaries

    Chapter SummariesIn addition to this preface, this document contains the following chapters: Chapter 1, About the Platform SDKs, on page 13. This chapter

    introduces the Platform SDKs and gives an overview of how to use them. Chapter 2, About the Code Examples, on page 25. This chapter discusses

    how the code examples that come with the Platform SDK are packaged, how to use them, and how they work.

    Document ConventionsThis document uses certain stylistic and typographical conventionsintroduced herethat serve as shorthands for particular kinds of information.

    Document Version Number

    A version number appears at the bottom of the inside front cover of this document. Version numbers change as new information is added to this document. Here is a sample version number:72sdk_dev_platform_03-2006_v7.2.000.01

    You will need this number when you are talking with Genesys Technical Support about this product.

    Type Styles

    Italic

    In this document, italic is used for emphasis, for documents titles, for definitions of (or first references to) unfamiliar terms, and for mathematical variables.

    Examples: Please consult the Genesys 7 Migration Guide for more information. A customary and usual practice is one that is widely accepted and used

    within a particular industry or profession. Do not use this value for this option. The formula, x +1 = 7 where x stands for . . .

    Monospace Font

    A monospace font, which looks like teletype or typewriter text, is used for all programming identifiers and GUI elements. This convention includes the names of directories, files, folders, configuration objects, paths, scripts, dialog boxes, options, fields, text and list boxes,

  • Developers Guide 9

    Preface Document Conventions

    operational modes, all buttons (including radio buttons), check boxes, commands, tabs, CTI events, and error messages; the values of options; logical arguments and command syntax; and code samples.

    Examples: Select the Show variables on screen check box. Click the Summation button. In the Properties dialog box, enter the value for the host server in your

    environment. In the Operand text box, enter your formula. Click OK to exit the Properties dialog box. The following table presents the complete set of error messages

    T-Server distributes in EventError events. If you select true for the inbound-bsns-calls option, all established

    inbound calls on a local agent are considered business calls.Monospace is also used for any text that users must manually enter during a configuration or installation procedure, or on a command line:

    Example: Enter exit on the command line.

    Screen Captures Used in This Document

    Screen captures from the product GUI (graphical user interface), as used in this document, may sometimes contain a minor spelling, capitalization, or grammatical error. The text accompanying and explaining the screen captures corrects such errors except when such a correction would prevent you from installing, configuring, or successfully using the product. For example, if the name of an option contains a usage error, the name would be presented exactly as it appears in the product GUI; the error would not be corrected in any accompanying text.

    Square Brackets

    Square brackets indicate that a particular parameter or value is optional within a logical argument, a command, or some programming syntax. That is, the parameters or values presence is not required to resolve the argument, command, or block of code. The user decides whether to include this optional information. Here is a sample:smcp_server -host [/flags]

  • 10 Platform SDK 7.2

    Preface Related Resources

    Angle Brackets

    Angle brackets indicate a placeholder for a value that the user must specify. This might be a DN or port number specific to your enterprise. Here is a sample:smcp_server -host

    Related ResourcesConsult these additional resources as necessary: Platform SDK 7.2 Deployment Guide, which contains important

    configuration and installation information.

    Platform SDK 7.2 API Reference for the particular SDK you are using, which provides the authoritative information on methods, functions, and events for your SDK.

    Platform SDK 7.2 Application Block Guide for the particular application block you are using. Each Guide explains how to use the application block and documents all code used in the application block itself. (Application blocks are production-quality available code.)

    Platform SDK 7.2 Code Examples for the particular SDK you are using, which offer illustrative ways to begin using your SDK. These code examples are fully functioning software applications, but are for educational purposes only and are not supported.

    The Deployment Guides for the underlying Genesys servers with which you intend to have your Platform SDK applications integrate. For instance, be sure to check the Framework 7.2 SIP Server Deployment Guide if you plan on using the Voice Platform SDK and the SIP Endpoint Application Block.

    Other Genesys SDK documentation for extended information on ways to integrate custom applications with Genesys Servers. This includes documents such as the T-Library SDK 7.2 C Developers Guide, which contains detailed information on the TLIB protocol and on message exchanges with T-Servers. All Genesys SDK documentation is available from the Technical Support website and is also located on the SDK Documentation CD and on your product CD.

    The Genesys Technical Publications Glossary, which ships on the Genesys Documentation Library CD and which provides a comprehensive list of the Genesys and CTI terminology and acronyms used in this document.

  • Developers Guide 11

    Preface Making Comments on This Document

    The Genesys 7 Migration Guide, also on the Genesys Documentation Library CD, which provides a documented migration strategy from Genesys product releases 5.1 and later to all Genesys 7.x releases. Contact Genesys Technical Support for additional information.

    The Release Notes and Product Advisories for this product, which are available on the Genesys Technical Support website at http://genesyslab.com/support.

    Information on supported hardware and third-party software is available on the Genesys Technical Support website in the following documents: Genesys 7 Supported Operating Systems and Databases Genesys 7 Supported Media InterfacesGenesys product documentation is available on the: Genesys Technical Support website at http://genesyslab.com/support. Genesys Documentation Library CD, which you can order by e-mail from

    Genesys Order Management at [email protected].

    Making Comments on This DocumentIf you especially like or dislike anything about this document, please feel free to e-mail your comments to [email protected]. You can comment on what you regard as specific errors or omissions, and on the accuracy, organization, subject matter, or completeness of this document. Please limit your comments to the information in this document only and to the way in which the information is presented. Speak to Genesys Technical Support if you have suggestions about the product itself.When you send us comments, you grant Genesys a nonexclusive right to use or distribute your comments in any way it believes appropriate, without incurring any obligation to you.

  • 12 Platform SDK 7.2

    Preface Making Comments on This Document

  • Developers Guide 13

    Chapter

    1 About the Platform SDKsThe five Platform SDKs allow you to handle voice and open media interactions, write custom media servers, manage outbound campaigns, work with statistics, and manage your Genesys configuration.This chapter gives you a brief outline of the purpose of the individual SDKs. Then it introduces the common foundation of these Platform SDKs. It contains the following sections:z The Platform SDKs, page 13z Getting Started, page 15z Architecture of the Platform SDKs, page 17z Sending and Receiving Messages, page 17z Namespace Structure, page 23

    The Platform SDKsThis section gives you a simple introduction to each of the Platform SDKs. It ends with Table 1, which shows the servers each of the Platform SDKs connects with, and gives the names of the protocols that are used to communicate with each server. This table also shows which development platforms are supported by each SDK.

    VoiceThe Voice Platform SDK enables you to use Java or .NET to design applications that monitor and handle voice interactions from a traditional or IP-based telephony device.

  • 14 Platform SDK 7.2

    Chapter 1: About the Platform SDKs The Platform SDKs

    Open MediaWith the Open Media Platform SDK, you can build .NET or Java applications that feed open media interactions into your Genesys environment, or applications that act as custom media servers to perform external service processing (ESP) on interactions that have already entered it.

    Outbound ContactThe Outbound Contact Platform SDK can be used to build .NET applications that allow you to manage outbound campaigns. (This SDK will support Java as well in future releases.)

    StatisticsUse the Statistics Platform SDK to build .NET applications that solicit and monitor statistics from your Genesys environment. (This SDK will support Java as well in future releases.)

    ConfigurationThe Configuration Platform SDK enables you to build Java or .NET applications that add, modify, and delete information in the Configuration Layer of your Genesys environment.

    * These Platform SDKs will support Java in a forthcoming release.

    Table 1: The Platform SDKs

    SDK Name Server Protocol .NET Java

    Voice Platform SDK T-Servers TLIB X X

    Open Media Platform SDK

    Interaction Server ITX, ESP X X

    Outbound Contact Platform SDK

    Outbound Contact Server

    CMLIB X *

    Statistics Platform SDK

    Stat Server STATLIB X *

    Configuration Platform SDK

    Configuration Server

    CFGLIB X X

  • Developers Guide 15

    Chapter 1: About the Platform SDKs Getting Started

    Getting StartedThe Platform SDKs enable you to write client or server applications that use messages to communicate with Genesys servers.Each SDK has one or more Protocol objects that you can use in your client applications to establish communication with the appropriate server. This guide includes two types of examples. The first type of example uses a generic [Genesys Server Name]Protocol object. If you copy one of these examples, you will have to supply the correct Protocol object name for the Platform SDK you are writing with, as shown in Table 2. This guide also uses examples drawn from the individual Platform SDKs.

    The first thing you have to do to use a Platform SDK is create a Protocol object and open a communication channel with the server. Once you have done this, most of the rest of your SDK-related work will involve sending and receiving messages.Here is a generic example of how to create a Protocol object and open the communication channel. Note that you must provide the Protocol object with information about the server you want to connect with:

    [C# and Java]

    [Genesys Server Name]Protocol serverProtocol = new [Genesys Server Name]Protocol( new Endpoint( serverName, serverUri));

    Here is the same task, written for the Voice Platform SDK. In this case, you need to instantiate a TServerProtocol object:

    Table 2: Platform SDK Protocol Objects

    SDK Name Server Protocol Object

    Voice Platform SDK T-Servers TServerProtocol

    Open Media Platform SDK

    Interaction Server InteractionServerProtocol

    Outbound Contact Platform SDK

    Outbound Contact Server

    OutboundServerProtocol

    Statistics Platform SDK Stat Server StatServerProtocol

    Configuration Platform SDK

    Configuration Server ConfServerProtocol

  • 16 Platform SDK 7.2

    Chapter 1: About the Platform SDKs Getting Started

    [C# and Java]

    TServerProtocol tServerProtocol = new TServerProtocol(

    new Endpoint(tServerName,tServerUri));

    Note: The code examples in this book are designed to help you write applications in C# and Java, which often have identical syntax. When the syntax is different, the examples are provided in both languages.Also, C# uses properties in situations where Java might use getter and setter methods. To promote a common understanding, this book uses the terms field and variable in these situations.

    At this point, you may need to set the values of one or more of the Protocol objects fields. For instance, the InteractionServerProtocol object used in the Open Media Platform SDK requires that you set the client type:

    [C#]

    interactionServerProtocol.ClientType =InteractionClient.AgentApplication;

    [Java]

    interactionServerProtocol.setClientType(InteractionClient.AgentApplication);

    Once you have created the Protocol object, you need to open a connection to the server:

    [C#]

    serverProtocol.Open();

    [Java]

    serverProtocol.open();

    You are now ready to send and receive messages. But before learning how to do that, lets take a look at the architecture of the Platform SDKs.

  • Developers Guide 17

    Chapter 1: About the Platform SDKs Architecture of the Platform SDKs

    Architecture of the Platform SDKsYou can write server applications with the Open Media Platform SDK, but this introduction focuses on client application development.From a conceptual standpoint, your applications Protocol object will be communicating directly with the appropriate server using the server's protocol running on TCP/IP, as shown in Figure 1.

    Figure 1: Conceptual Model of Client/Server Communication

    Sending and Receiving MessagesOnce you have opened a connection to the server, you are ready to send and receive messages. The Platform SDK supports two message exchange patterns. In some cases, you will need to follow the Request/Response pattern. That is, you will send a message and wait for a response, as shown in Figure 2. At other times, following the Unsolicited Event pattern, you simply need to wait for unsolicited messages of a certain type, as shown in Figure 3.

    Figure 2: Request and Response

    Client Application

    Genesys ServerGenesysServer-Protocol

    GenesysServer Protocol/

    TCP/IP

    Client Server

    Request

    Response

  • 18 Platform SDK 7.2

    Chapter 1: About the Platform SDKs Sending and Receiving Messages

    Figure 3: Unsolicited Event

    The messages you send will be in the form of Request classes, such as RequestAgentLogin or RequestAnswerCall. The messages you receive, whether solicited or not, will be in the form of Event classes, such as EventAck or EventDialing.

    Requests and ResponsesYou will normally want to use threads in your message-handling code. So before getting into how to send and receive messages, let's set up some thread-handling code. Since this code will be fairly different in Java and C#, there are separate sections for each language.

    Thread-Handling in C#

    The first thing to do in C# is set up a method that receives messages and runs in its own thread. Here is a sample method called ReceiveMessages() :

    [C#]

    private void ReceiveMessages(){

    while (isRunning){

    if([Genesys Server Name]Protocol.State != ChannelState.Opened){

    System.Threading.Thread.Sleep(500);continue;

    }

    IMessage response = [Genesys Server Name]Protocol.Receive();

    Client Server

    Event

  • Developers Guide 19

    Chapter 1: About the Platform SDKs Sending and Receiving Messages

    if(response != null){

    // Call a user-defined function that does the actual work:checkReturnMessage(response);

    }}

    }

    You need to define the thread, too:

    [C#]

    private Thread receiver;

    And initialize it, perhaps in your constructor call:

    [C#]

    receiver = new Thread(new ThreadStart(this.ReceiveMessages));

    Now, in the main thread, before you call [Genesys Server Name]Protocol.Open(), you need to start the new thread:

    [C#]

    receiver.Start();serverProtocol.Open();

    Thread-Handling in Java

    Your first step in setting up thread-handling for a Java application will be to set up a class that receives messages and runs in its own thread. Here is a sample class called MessageReceiver:

    [Java]

    class MessageReceiver extends Thread {

    MessageReceiver ([Genesys Server Name]Protocol serverProtocol) { this.serverProtocol = serverProtocol; } // This method will receive all messages: public void run() { while (true) { Message message = serverProtocol.receive();

  • 20 Platform SDK 7.2

    Chapter 1: About the Platform SDKs Sending and Receiving Messages

    // Calling a method that does the actual work: handleMessage(message);

    } }

    private void handleMessage(IMessage message) { // Some user-specific work... }}

    In the main thread, before you call [Genesys Server Name]Protocol.open(), you need to instantiate MessageReceiver and start it as a new thread:

    [Java]

    MessageReceiver messageReceiver = new MessageReceiver(this.serverProtocol);

    new Thread(messageReceiver).start();

    serverProtocol.open();

    Sending and Receiving Messages

    Once your thread is ready, you can start to send and receive messages. For example, if you are using the Open Media Platform SDK, you may want to log in an agent. To do this, you need to let the server know that you want to log in. And then you need to wait for confirmation that your login was successful.The first thing you need to do is create a login request, as shown here:

    [C#]

    RequestAgentLogin requestAgentLogin = RequestAgentLogin.Create(

    tenantId,placeId,reason);

    [Java]

    RequestAgentLogin requestAgentLogin = RequestAgentLogin.create(

    tenantId,placeId,reason);

    This version of RequestAgentLogin.Create specifies most of the information you will need to perform the login, but there is one more piece of data

  • Developers Guide 21

    Chapter 1: About the Platform SDKs Sending and Receiving Messages

    required. You could use another version of the Create method, but that version would require you to specify every possible parameter for the request. It is probably simpler to set the value of the one field you need, like this:

    [C#]

    requestAgentLogin.MediaList = mediaList;

    [Java]

    requestAgentLogin.setMediaList(mediaList);

    Once you have created the request and set any required fields, you can continue in two different ways. You could Send the request and then wait for the response:

    [C#]interactionServerProtocol.Send(requestAgentLogin);// Replace the Receive statement shown in the ReceiveMessages // method with this statement:IMessage respondingEvent = interactionServerProtocol.Receive();

    [Java]interactionServerProtocol.send(requestAgentLogin);// Replace the receive() statement shown in the MessageReceiver// class with this statement:Message respondingEvent = interactionServerProtocol.receive();

    In this case, the Receive method will block until a message returns from the server.But you can also combine the Send and Receive into a single method call by using the Request method, like this:

    [C#]IMessage respondingEvent =

    interactionServerProtocol.Request(requestAgentLogin);

    [Java]Message respondingEvent =

    interactionServerProtocol.request(requestAgentLogin);

    The result is the same, but the code is a little cleaner.As shown in the above code samples, the response to your request will come in the form of an IMessage (C#) or a Message (Java). This is the interface implemented by all events in the Platform SDK. Some requests will be answered by an event that is specific to the request, while others will receive a more generic response of EventAck, which simply acknowledges that your request was successful. If a request fails, the server will send an EventError.

  • 22 Platform SDK 7.2

    Chapter 1: About the Platform SDKs Sending and Receiving Messages

    A successful RequestAgentLogin will receive an EventAck, while an unsuccessful one will receive an EventError. You can use a switch statement to test which response you received, as outlined here:

    [C#]

    switch(respondingEvent.Id){

    case EventAck.MessageId:// The request succeeded, carry out appropriate processing...case EventError.MessageId:// The request failed, carry out appropriate processing......

    }

    [Java]

    switch(response.messageId()){ case EventAck.ID: // The request succeeded, carry out appropriate processing... case EventError.ID: // The request failed, carry out appropriate processing... ...}

    Unsolicited EventsThere are times when you need to receive unsolicited events. For example, if you are using the Open Media Platform SDK, you may want to indicate that an agent is ready to receive Open Media interactions. In that case you will use the Receive method, like this:

    [C#]IMessage unsolicitedEvent = interactionServerProtocol.Receive();

    [Java]Message unsolicitedEvent = interactionServerProtocol.receive();

    You will normally want to wrap this statement into its own thread, as shown in the section on Requests and Responses on page 18. As you also saw in that section, the Receive method blocks until a message returns from the server. In this case, your application is waiting for an EventInvite. As with the EventAck above, you can use a switch statement to determine whether you have received the desired response:

  • Developers Guide 23

    Chapter 1: About the Platform SDKs Namespace Structure

    [C#]

    switch(unsolicitedEvent.Id){ case EventInvite.MessageId: // An invitation has been issued, do whats needed... case EventError.MessageId: // There has been an error, do whats needed... ...}

    [Java]

    switch(unsolicitedEvent.messageId()){ case EventInvite.ID: // An invitation has been issued, do whats needed... case EventError.ID: // There has been an error, do whats needed... ...}

    Namespace StructureThe Platform SDKs share a common design. This includes the structure of the namespaces they use.

    Note: In this book, namespace is used as a generic term for what are called packages in Java and namespaces in C#.

    Commons NamespacesThere are several namespaces that are used by every Platform SDK. The .NET versions have the following names: Genesyslab.Platform.Commons.Collections Genesyslab.Platform.Commons.Connection Genesyslab.Platform.Commons.Logging Genesyslab.Platform.Commons.ProtocolsHere are the names used in the Java versions: com.genesyslab.platform.commons.collections com.genesyslab.platform.commons.connection com.genesyslab.platform.commons.logging com.genesyslab.platform.commons.protocolMost of the types in these namespaces are for Genesys internal use only.

  • 24 Platform SDK 7.2

    Chapter 1: About the Platform SDKs Namespace Structure

    Note: The SDK product distributions also include Genesyslab.Core or com.genesyslab.core. The namespaces included in these root namespaces are also for Genesys internal use only. They are not documented in any way.

    SDK-Specific NamespacesIn addition, each of the individual SDKs has its own namespaces. These namespaces concern protocols, events and requests associated with the individual SDKs, and have names like this for .NET: Genesyslab.Platform..Protocols. Genesyslab.Platform..Protocols..Events Genesyslab.Platform..Protocols..Requests

    and this for Java: com.genesyslab.platform..protocol. com.genesyslab.platform..protocol..events

    com.genesyslab.platform..protocol..requests

    In some cases, there are several of these namespaces, as in the Voice Platform SDK for .NET: Genesyslab.Platform.Voice.Protocols.TServer.Requests.Agent Genesyslab.Platform.Voice.Protocols.TServer.Requests.Dn Genesyslab.Platform.Voice.Protocols.TServer.Requests.Dtmf Genesyslab.Platform.Voice.Protocols.TServer.Requests.Iscc Genesyslab.Platform.Voice.Protocols.TServer.Requests.Party Genesyslab.Platform.Voice.Protocols.TServer.Requests.Queries Genesyslab.Platform.Voice.Protocols.TServer.Requests.Special Genesyslab.Platform.Voice.Protocols.TServer.Requests.Userdata Genesyslab.Platform.Voice.Protocols.TServer.Requests.Voicemailand in the Voice Platform SDK for Java: com.genesyslab.platform.voice.protocol.tserver.requests.agent com.genesyslab.platform.voice.protocol.tserver.requests.dn com.genesyslab.platform.voice.protocol.tserver.requests.dtmf com.genesyslab.platform.voice.protocol.tserver.requests.iscc com.genesyslab.platform.voice.protocol.tserver.requests.party com.genesyslab.platform.voice.protocol.tserver.requests.queries com.genesyslab.platform.voice.protocol.tserver.requests.special com.genesyslab.platform.voice.protocol.tserver.requests.userdata com.genesyslab.platform.voice.protocol.tserver.requests.voicemail

  • Developers Guide 25

    Chapter

    2 About the Code ExamplesThis chapter introduces the code examples that accompany this developers guide. It contains the following section:z Setup for Development, page 25z Open Media Examples, page 27z Voice Examples, page 36z Statistics Example, page 42

    Setup for DevelopmentWhen you install the Platform SDK, be sure that you have the required tools, environment-variable values, and configuration data. See the Platform SDK 7.2 Deployment Guide for details. The Platform SDK includes all Genesys libraries and third-party libraries needed for proper operation, while the Genesys Developer Documentation CD includes the Platform SDK code examples and a PDF version of this developers guide.

    Source-Code Examples Discussions in subsequent chapters of this guide refer to the supplied source-code examples. These examples are provided on the Genesys Documentation CD in a .zip archive file.

    Note: The current examples are for C# only.

    The code examples illustrate the use of some common features of the Platform SDKs. The examples are not tested and are not supported by Genesys.

  • 26 Platform SDK 7.2

    Chapter 2: About the Code Examples Setup for Development

    Note: When writing applications that use the Platform SDKs, you will probably need to set up separate threads for message-handling. Voice Examples on page 36 shows sample techniques for this. The Open Media examples are more simple and carry out all of their activity in a single thread.

    Required Third-Party ToolsYou can develop applications with the Platform SDK in Java or in .NET languages. In order to develop Java applications, you will need a compiler, such as the one delivered in the Java 2 Platform, Standard Edition, Development Kit (JDK), version 1.4.2, from Sun Microsystems.To develop .NET applications, you will need .NET Framework 1.1 or higher. If you are using Visual Studio, you will need Visual Studio 2003 or higher.In this guide, the Visual Studio 2003 was used to compile and run the code examples.

    Environment Setup

    .NET

    In order to compile and run, Visual Studio needs access to the Platform SDK libraries. They are located in the bin/ subdirectory of the Platform SDK product installation directory.

    Add references to all of these libraries to your Visual Studio projects.

    Java

    In order to compile and run, the compiler or the JVM needs access to the libraries of the Platform SDK. They are located in the lib/ subdirectory of the Platform SDK product installation directory. Set the following environment variables: Specify all Platform SDK .jar files in the CLASSPATH environment variable. Specify the location of the Java Runtime Environment in the JAVA_HOME

    environment variable.

  • Developers Guide 27

    Chapter 2: About the Code Examples Open Media Examples

    Building the ExamplesTo build one of the C# examples described in this document: Open the example in Visual Studio Add references to the Platform SDK library, as mentioned in the section on

    environment setup Build the example

    Configuration DataFor the examples provided for this document to work, they need valid configuration data, including connections to servers and configuration objects such as Place, Dn, Agent, and so on. See the Platform SDK 7.2 Deployment Guide for configuration details.

    Open Media ExamplesThere are two Open Media examples. The first example is a simple media server that submits a new Open Media interaction. The second example is a client application that can accept an Open Media interaction for processing. Once an interaction has been accepted, the application allows an agent to read information about the interaction and mark it as completed.

    Open Media Server ExampleThis example is very simple. The user interface has a single button that submits an Open Media interaction using information that has been hard-coded in the application. It also has a window that displays information about the interaction, as shown in Figure 4.

  • 28 Platform SDK 7.2

    Chapter 2: About the Code Examples Open Media Examples

    Figure 4: Open Media Server Example User Interface

    To use this application, you need to set up some information about your environment. Find the following statements in the source code for Form1.cs, and enter values that match your Genesys Configuration Layer:

    // Enter configuration information here:private string interactionServerName = "";private string interactionServerHost = "";private int interactionServerport = ;private int tenantId = 101;private string inboundQueue = "";private string mediaType = "";// End of configuration information.

    Once you have entered this information, you can run the program. Click the Create Interaction button, and if the interaction was successfully created, you should soon see this message:

    Response: EventAck

    Now that you have seen what the program does, lets take a look at how it works.Since this custom media server is such a simple program, almost all of the code you need to understand is in the InteractionButton_Click method, which is called when you click the Create Interaction button. The first thing this method does is create a URI, using the server and host information you entered in the configuration section of the program. It then uses that information to create a new InteractionServerProtocol object, as shown here:

  • Developers Guide 29

    Chapter 2: About the Code Examples Open Media Examples

    interactionServerUri = new Uri("tcp://" + interactionServerHost + ":" + interactionServerport);

    InteractionServerProtocol interactionServerProtocol =new InteractionServerProtocol(new Endpoint(interactionServerName, interactionServerUri));

    Now the code specifies the client name and type. This is also a good time to set up some user data for the new interaction. In this case, the code shows how to add a subject to the new interaction.

    interactionServerProtocol.ClientName = "EntityListener";interactionServerProtocol.ClientType =

    InteractionClient.MediaServer;

    KeyValueCollection userData =new KeyValueCollection();

    userData.Add("Subject", "New Interaction Created by a Custom Media Server");

    With this basic setup accomplished, it is time to open the Protocol object, and then submit a new interaction, as you see here:

    try{

    interactionServerProtocol.Open();

    RequestSubmit requestSubmit = RequestSubmit.Create(inboundQueue,mediaType,"Inbound");

    requestSubmit.TenantId = tenantId;requestSubmit.InteractionSubtype = "InboundNew";requestSubmit.UserData = userData;

    Once the request has been processed, you will receive a message from Interaction Server, which will then be printed to the information pane of your application:

    IMessage response =interactionServerProtocol.Request(requestSubmit);

    LogAreaRichTextBox.Text = LogAreaRichTextBox.Text+ "Response: " + response.Name + ".\n\n";

  • 30 Platform SDK 7.2

    Chapter 2: About the Code Examples Open Media Examples

    Open Media Client ExampleThis example enables an agent to receive an Open Media interaction, accept it for processing, and mark it done. As you can see in Figure 5, the example has buttons to log an agent in and out and to make the agent ready or not ready. Once the agent has logged in, he or she can click the Receive button to receive an interaction, and then click the Accept button to accept it.

    Figure 5: Open Media Client Example User Interface

    Figure 6 shows the information supplied by the application after an agent has accepted an interaction and marked it done.

  • Developers Guide 31

    Chapter 2: About the Code Examples Open Media Examples

    Figure 6: A Completed Interaction

    To use this application, you need to set up some information about your environment. Find the following statements in the source code for Form1.cs, and enter values that match your Genesys Configuration Layer:

    // Enter configuration information here:private string mediaType = "";private string placeId = "";private string interactionServerName = "";private string interactionServerHost = "";private int interactionServerport = ;// End of configuration information.

    Once you have set up the configuration information, you can run the application. Here is what it does.When the application starts, the Form1 constructor code sets the state of the buttons in the user interface. Then it adds your media type to a list of the media types your agent will use while logged in. Finally, it builds the URI for the Interaction Server:

    LoginButton.Enabled = true;ReadyButton.Enabled = false;LogoutButton.Enabled = false;

  • 32 Platform SDK 7.2

    Chapter 2: About the Code Examples Open Media Examples

    NotReadyButton.Enabled = false;ReceiveInviteButton.Enabled = false;AcceptInteractionButton.Enabled = false;DoneButton.Enabled = false;mediaList.Add(mediaType, 1);interactionServerUri = new Uri("tcp://" + interactionServerHost

    + ":" + interactionServerport);

    Once the application is running, your agent can log in. Clicking the Log In button will run the LoginButton_Click method, which first checks to see whether the InteractionServerProtocol has been created. If not, the following code is executed, creating a new protocol object and opening a connection to Interaction Server:

    interactionServerProtocol = new InteractionServerProtocol(new Endpoint(interactionServerName,interactionServerUri));

    interactionServerProtocol.ClientType = InteractionClient.AgentApplication;

    interactionServerProtocol.Open();writeToLogArea("InteractionServerProtocol object created. "

    + "\nConnected to " + interactionServerUri + "\n\n");protocolObjectCreated = true;

    At this point, the agent can be logged in, using the media list created in the constructor call. The first step is to create the login request and set up the media list:

    try{

    RequestAgentLogin requestAgentLogin = RequestAgentLogin.Create(101,placeId,null);

    requestAgentLogin.MediaList = mediaList;

    Now the message can be sent to the server. The Request method does the sending and then waits for a response:

    IMessage respondingEvent = interactionServerProtocol.Request(requestAgentLogin);

    When the response comes in, the code checks to see whether it was successful, and then updates the user interface to reflect the agents new status:

  • Developers Guide 33

    Chapter 2: About the Code Examples Open Media Examples

    if (checkReturnMessage(requestAgentLogin.Name, respondingEvent)){

    LoginButton.Enabled = false;ReadyButton.Enabled = false;LogoutButton.Enabled = true;NotReadyButton.Enabled = true;ReceiveInviteButton.Enabled = true;

    }}catch (ProtocolException protocolException){

    MessageBox.Show("Protocol Exception!\n" + protocolException);}

    Note that the first line of this snippet calls the checkReturnMessage method. This method handles return messages for several of the requests issued in the sample application. As you can see from its signature, this method uses the request type and the response from the server as input. It returns a Boolean value indicating whether the request was successful.

    private bool checkReturnMessage(string requestType, IMessage respondingEvent)

    The body of the method sets the Boolean to false, initializes the message that will be printed to the information pane, and determines which event message was received from the server. If an acknowledgement message was received, the Boolean is set to true. In any case, a message is written to the information pane:

    bool success = false;string messageText = "";switch(respondingEvent.Id){

    case EventAck.MessageId: // 125messageText = requestType + " succeeded.\n\n";success = true;break;

    case EventError.MessageId: // 126messageText = requestType + " failed with an error: \n"

    + respondingEvent.ToString() + "\n";break;

    default:messageText = "Unexpected Event: "

    + respondingEvent.Name + "\n"+ "Responding Event ID = " + respondingEvent.Id + "\n"+ respondingEvent.ToString() + "\n";

    break;}

  • 34 Platform SDK 7.2

    Chapter 2: About the Code Examples Open Media Examples

    writeToLogArea(messageText);return success;

    Now the agent can click the Receive button. This triggers the ReceiveInviteButton_Click method. This method issues a Receive method, which waits for a response from the server:

    IMessage unsolicitedEvent = interactionServerProtocol.Receive();

    If the method times out, the code indicates to the agent that the queue is empty:

    if (unsolicitedEvent == null) {

    LogAreaRichTextBox.Text = LogAreaRichTextBox.Text+ "The queue is empty!\n\n";

    }

    Otherwise, the code determines whether the servers response is an invitation to process an interaction:

    switch(unsolicitedEvent.Id){

    case EventInvite.MessageId: // We are invited...LogAreaRichTextBox.Text = LogAreaRichTextBox.Text

    + "EventInvite received.\n\n";invitationReceived = true;break;

    case EventError.MessageId: // 126LogAreaRichTextBox.Text = LogAreaRichTextBox.Text

    + "EventInvite failed with an error: \n"+ unsolicitedEvent.ToString() + "\n";

    break;default:

    LogAreaRichTextBox.Text = LogAreaRichTextBox.Text+ "Unexpected Event: " + unsolicitedEvent.Name + "\n"+ "Responding Event ID = " + unsolicitedEvent.Id + "\n"+ unsolicitedEvent.ToString() + "\n";

    break;}

    If the agent has been invited to process an interaction, the code prints information about it in the information window at the bottom of the user interface:

    if (invitationReceived){

    EventInvite eventInvite = (EventInvite) unsolicitedEvent;incomingInteractionTicketId = eventInvite.TicketId;

  • Developers Guide 35

    Chapter 2: About the Code Examples Open Media Examples

    incomingInteractionProperties = eventInvite.Interaction;incomingInteractionName = eventInvite.Interaction.InteractionId;AcceptInteractionButton.Enabled = true;LogAreaRichTextBox.Text = LogAreaRichTextBox.Text

    + "incomingInteractionTicketId: " + incomingInteractionTicketId + "\n"

    + "eventInvite.TicketId: " + eventInvite.TicketId + "\n" + "eventInvite.Interaction.InteractionId: " + eventInvite.Interaction.InteractionId + "\n\n";

    }

    Here is a sample of what might be printed there:

    incomingInteractionTicketId: 5eventInvite.TicketId: 5eventInvite.Interaction.InteractionId: 036H752427CBX002

    Now the agent can click the Accept button, which triggers a request to accept the interaction:

    RequestAccept requestAccept = RequestAccept.Create(incomingInteractionTicketId, incomingInteractionName);

    The code then checks the response, and if the response is favorable, it updates buttons on the user interface and prints information about the interaction in the Interaction Information pane:

    IMessage respondingEvent =interactionServerProtocol.Request(requestAccept);

    if (checkReturnMessage(requestAccept.Name, respondingEvent)){

    ReceiveInviteButton.Enabled = false;AcceptInteractionButton.Enabled = false;DoneButton.Enabled = true;InteractionInfoRichTextBox.Text =

    "Interaction ID: " + requestAccept.InteractionId + "\n"...+ "\n";

    }

    Here is a sample of what might be printed about an interaction created by the Open Media Server example:

  • 36 Platform SDK 7.2

    Chapter 2: About the Code Examples Voice Examples

    Interaction ID: 036H752427CBX002Queue: OMProcessingInteraction Subtype: InboundNewSubject: New Interaction Created by a Custom Media ServerReceived At: 3/10/2006 9:33:19 PM

    The agent can view this interaction, and then click the Done button.

    RequestStopProcessing requestStopProcessing = RequestStopProcessing.Create(incomingInteractionProperties.InteractionId,null);

    IMessage respondingEvent = interactionServerProtocol.Request(requestStopProcessing);

    if (checkReturnMessage(requestStopProcessing.Name, respondingEvent)){

    DoneButton.Enabled = false;}

    At this point, the agent can log out, triggering the following code, which sends the logout request and checks the response. If the response is successful, the buttons on the user interface are updated:

    RequestAgentLogout requestAgentLogout = RequestAgentLogout.Create();

    IMessage respondingEvent = interactionServerProtocol.Request(requestAgentLogout);

    if (checkReturnMessage(requestAgentLogout.Name, respondingEvent)){

    LoginButton.Enabled = true;ReadyButton.Enabled = false;LogoutButton.Enabled = false;NotReadyButton.Enabled = false;ReceiveInviteButton.Enabled = false;AcceptInteractionButton.Enabled = false;DoneButton.Enabled = false;

    }

    Voice ExamplesThese examples demonstrate how to log an agent in and out, and how to make him or her ready and not ready. They also show how to make and receive a call, how to put the call on hold and then retrieve it, and how to release the call. The user interface for these examples contains several groups of buttons and an information pane, as shown in Figure 7.

  • Developers Guide 37

    Chapter 2: About the Code Examples Voice Examples

    Figure 7: Voice Examples User Interface

    To use this example, you will have to set up configuration information in the following lines of Form1.cs. Note that not all switches require a user name and password, but they are shown here in case your switch does require them:

    // Enter configuration information here:private string tServerName = "";private string tServerHost = "";private int tServerport = ;private string thisDN = "";private string userName = "";private string password = "";private string thisQueue = "";// End of configuration information.

    Once you have set up the configuration information, you can run the example. When you start the application, the constructor creates the T-Server URI and sets up a thread that will receive messages from the server. It also sets the state of buttons in the user interface, the code for which is not shown here:

    tServerUri = new Uri("tcp://" + tServerHost + ":" + tServerport);receiver = new Thread(new ThreadStart(this.ReceiveMessages));

    When the application starts, you can log in. After you log in, your user interface will look something like Figure 8. As you can see, the Log In button is disabled, while the Log Out and Not Ready buttons are now enabled.

  • 38 Platform SDK 7.2

    Chapter 2: About the Code Examples Voice Examples

    I

    Figure 8: After Logging In

    When you click the log in button, several things happen. First the code checks to see if a TServerProtocol object has been created. If not, it executes the createProtocolObject() method.This method creates a new protocol object and then sets a flag to indicate that the application is running. This flag is used by the message-handling thread. Then the method opens a connection to the server:

    tServerProtocol = new TServerProtocol(new Endpoint(tServerName,tServerUri));

    isRunning = true;receiver.Start();tServerProtocol.Open();writeToLogArea("TServerProtocol object created. "

    + "\nConnected to " + tServerUri + "\n\n");protocolObjectCreated = true;

    After creating the protocol object, the application issues a request to register the DN you will be using in your session. This must happen before you can log in:

    RequestRegisterAddress requestRegisterAddress = RequestRegisterAddress.Create(thisDN,RegisterMode.ModeShare,

  • Developers Guide 39

    Chapter 2: About the Code Examples Voice Examples

    ControlMode.RegisterDefault,AddressType.DN);

    IMessage response = tServerProtocol.Request(requestRegisterAddress);

    After sending this request, the application checks the response from the server and sends a request to log in. After checking the response, the application updates the state of several buttons in the user interface:

    checkReturnMessage(response);RequestAgentLogin requestAgentLogin =

    RequestAgentLogin.Create(thisDN,AgentWorkMode.AutoIn);

    requestAgentLogin.ThisQueue = thisQueue;// Your switch may not need a user name and password:requestAgentLogin.AgentID = userName;requestAgentLogin.Password = password;response = tServerProtocol.Request(requestAgentLogin);if (checkReturnMessage(response)){

    LoginButton.Enabled = false;ReadyButton.Enabled = false;LogoutButton.Enabled = true;NotReadyButton.Enabled = true;MakeCallButton.Enabled = true;

    }

    Since the login request also makes the agent ready, the Make Call button is now enabled. Before making a call, lets take a look at the message-handling code in the sample application.First off, there is a method that is waiting to receive messages as long as the isRunning switch is true. When a message is received from the server, this method calls the checkReturnMessage() method:

    private void ReceiveMessages(){

    while (isRunning){

    if(tServerProtocol.State != ChannelState.Opened){

    System.Threading.Thread.Sleep(500);continue;

    }

    IMessage response = tServerProtocol.Receive();

    if(response != null){

    checkReturnMessage(response);

  • 40 Platform SDK 7.2

    Chapter 2: About the Code Examples Voice Examples

    }}

    }

    The checkReturnMessage() method contains a switch statement that writes information to the user interface and returns a Boolean indicating whether it received an event it knows about. In some cases, only the Boolean is set, while in others, some slightly more complicated processing takes place. For instance, if the method processes an EventDialing message, it remembers the calls Connection ID:

    private bool checkReturnMessage(IMessage response){

    bool knownEvent = false;string messageText = "";switch(response.Id){

    case EventACK.MessageId:knownEvent = true;break;

    case EventAgentLogin.MessageId:knownEvent = true;break;

    case EventDialing.MessageId:EventDialing eventDialing = response as EventDialing;connId = eventDialing.ConnID;knownEvent = true;break;

    .

    .

    .case EventError.MessageId: // 126

    messageText = "EventError Received: \n"+ response.ToString() + "\n";

    break;default:

    messageText = "Unexpected Event: " + response.Name + "\n"+ "Responding Event ID = " + response.Id + "\n"+ response.ToString() + "\n";

    break;}if (knownEvent){

    writeToLogArea("Received " + response.Name + "\n\n");} else{

    writeToLogArea(messageText);}return knownEvent;

  • Developers Guide 41

    Chapter 2: About the Code Examples Voice Examples

    }

    Now that you have seen how messages are processed, here is how to make a call. First you have to fill in the Target DN field. Then click the Make Call button. At this point, the application requests the call. If the request is successful, the user interface is updated:

    RequestMakeCall requestMakeCall = RequestMakeCall.Create(thisDN,SinglepartyTargetDNTextBox.Text,MakeCallType.DirectAgent);

    IMessage response = tServerProtocol.Request(requestMakeCall);if (checkReturnMessage(response)){

    MakeCallButton.Enabled = false;HoldButton.Enabled = true;ReleaseButton.Enabled = true;

    }

    You can place this call on hold, then retrieve it. You can also release the call when you are finished.These examples also allow you to answer a call. When you receive an EventRinging, the checkReturnMessage() method saves the Connection ID and then checks to see whether the call is inbound. If it is, the Answer button is enabled:

    case EventRinging.MessageId:EventRinging eventRinging = response as EventRinging;connId = eventRinging.ConnID;if (eventRinging.ThisDN == thisDN){

    AnswerButton.Enabled = true;}knownEvent = true;break;

    When you click the Answer button, the application issues a request to answer the inbound call. Then it checks the response from the server and updates the user interface:

    RequestAnswerCall requestAnswerCall = RequestAnswerCall.Create(thisDN,connId);

    IMessage response = tServerProtocol.Request(requestAnswerCall);if (checkReturnMessage(response)){

  • 42 Platform SDK 7.2

    Chapter 2: About the Code Examples Statistics Example

    AnswerButton.Enabled = false;MakeCallButton.Enabled = false;HoldButton.Enabled = true;ReleaseButton.Enabled = true;

    }

    Statistics ExampleThis example shows how to subscribe to a statistic and have it updated periodically. Unlike some of the other examples, this one uses a separate thread to handle messages from the server. The user interface of this example is very simple, with one button that lets you retrieve statistics information based on values that are hard-coded in the application. Figure 9 shows the user interface.

    Figure 9: Statistics Example User Interface

    After clicking the Get Statistics button, you will periodically receive information similar to that shown in Figure 10.

  • Developers Guide 43

    Chapter 2: About the Code Examples Statistics Example

    Figure 10: Statistics Example User Interface with Statistics Data

    To use this example, you will have to set up configuration information in the following lines of Form1.cs:

    // Enter configuration information here:private string statServerHost = "";private int statServerport = ;private int clientID = ;private string clientName = "";private string tenantName = "Resources";private string dn = "@";// End of configuration information.

    When you start the application, the constructor sets up the Stat Server URI and sets up the thread that receives messages from the server:

    statServerUri = new Uri("tcp://" + statServerHost + ":" + statServerport);

    receiver = new Thread(new ThreadStart(this.ReceiveMessages));

    Once the application starts, you can click the Get Statistics button. The first thing the code does is create a StatServerProtocol object. Note that it is normally recommended that you identify your client application by name and ID.

  • 44 Platform SDK 7.2

    Chapter 2: About the Code Examples Statistics Example

    statServerProtocol =new StatServerProtocol(new Endpoint(statServerUri));

    statServerProtocol.ClientId = clientID;statServerProtocol.ClientName = clientName;

    Now the code set the Boolean value that tells the message receiver thread to start running and then opens the connection to the server:

    isRunning = true;receiver.Start();statServerProtocol.Open();

    At this point, its time to define some statistics. The first thing the code does is set up a statistics object. This object identifies the Configuration Layer object to collect information about, the objects type, and the tenant housing the object. In this case, the object is a DN:

    StatisticObject objectDescription = new StatisticObject(tenantName,

    dn, StatisticObjectType.RegularDN);

    Then the metrics for the statistic are identified. The most important one is the statistic type, which is identified in the constructor call:

    StatisticMetric statisticMetric = new StatisticMetric("TotalNumberInboundCalls");

    Other metrics include the time profile and range, and the filter:

    statisticMetric.TimeProfile = "CollectorDefault";statisticMetric.TimeRange = "Range0-120";statisticMetric.Filter = "VoiceCall";

    Once that statistics object and metrics have been defined, they are used to create a new statistic. Then a new statistics collection is instantiated, and the new statistic is added to the collection:

    Statistic inboundCalls = new Statistic(objectDescription, statisticMetric);

    StatisticsCollection statisticsCollection = new StatisticsCollection();

    statisticsCollection.AddStatistic(inboundCalls);

  • Developers Guide 45

    Chapter 2: About the Code Examples Statistics Example

    Finally, the code creates a Notification object, which gives the notification interval (in this case fifteen seconds), creates a request to open a statistics package, and sends the request to the server:

    Notification notification = Notification.Create(NotificationMode.Periodical, 15);

    RequestOpenPackage requestOpenPackage = RequestOpenPackage.Create(132,StatisticType.Historical,statisticsCollection,notification);

    statServerProtocol.Send(requestOpenPackage);

    When the package is opened, a message comes in from the server with statistics information. This message is handled by the ReceiveMessages() method. This method only does anything when the isRunning switch is turned on and when the channel to the server is opened:

    private void ReceiveMessages(){

    while (isRunning){

    if(statServerProtocol.State != ChannelState.Opened){

    System.Threading.Thread.Sleep(500);continue;

    }

    When those conditions are met, it will wait for a message from the server. When the message comes in, it is printed to the information pane at the bottom of the user interface:

    IMessage message = statServerProtocol.Receive();

    if(message != null){

    writeToLogArea(message.ToString() + "\n");}

    }}

    Here is a sample of the information that might be printed from the request to open the statistics package:

  • 46 Platform SDK 7.2

    Chapter 2: About the Code Examples Statistics Example

    'EventPackageOpened' ('2048')message attributes:XAL_PCKG_REQ_ID [int] = 2XAL_PCKG_ID [int] = 132

    When the statistics start arriving, the message receiver will print them. They might look something like this:

    'EventPackageInfo' ('2050')message attributes:XAL_PCKG_ERROR_STATISTICS_QTY [int] = 0XAL_PCKG_ID [int] = 132XAB_PCKG_DATA [bstr] = StatisticsCollection:Statistic:

    Tenant=ResourcesObjectId=7005@720_Avaya_SwitchObjectType=RegularDNStatisticType=TotalNumberInboundCallsTimeProfile=CollectorDefaultTimeRange=Range0-120Filter=VoiceCallError=0StringValue=0IntValue=0

    PackagedStatisticType [int] = 1 [Historical]Notification = ComplexClass:

    XAL_PCKG_NOTIFICATION_INTERVAL [int] = 8XAL_PCKG_NOTIFICATION_MODE [int] = 1 [Periodical]

    XAL_PCKG_REQ_ID [int] = 2XAL_PCKG_TM_SERVER [int] = 1142038000XAL_PCKG_SUCCESSFUL_STATISTICS_QTY [int] = 1

  • Developers Guide 47

    Index

    Symbols.NET Framework version. . . . . . . . . . . 26

    Aaccept interaction . . . . . . . . . . . . . . 30AddressType . . . . . . . . . . . . . . . . . 39AddStatistic() method . . . . . . . . . . . . 44agent login . . . . . . . . . . . . . . . . .20, 30agent not ready. . . . . . . . . . . . . . . . 30agent ready. . . . . . . . . . . . . . . . . . 30AgentWorkMode . . . . . . . . . . . . . . . 39answer call . . . . . . . . . . . . . . . . . . 41architecture of the Platform SDKs . . . . . . 17audience

    defining . . . . . . . . . . . . . . . . . . . 6

    Bbuilding the examples . . . . . . . . . . . . 27

    CC# . . . . . . . . . . . . . . . . . . . . . . 16

    thread-handling . . . . . . . . . . . . . . . 18call

    answer. . . . . . . . . . . . . . . . . . . . 41make. . . . . . . . . . . . . . . . . . . . . 41

    CDGenesys Developer Documentation. . . . . 25

    CFGLIB protocol . . . . . . . . . . . . . . . 14channel

    communication . . . . . . . . . . . . . . . 15chapter summaries

    defining . . . . . . . . . . . . . . . . . . . 8checkReturnMessage() method . . . .33, 39, 40CLASSPATH . . . . . . . . . . . . . . . . . 26client applications . . . . . . . . . . . . . . 17CMLIB protocol. . . . . . . . . . . . . . . . 14

    code examples. . . . . . . . . . . . . . . . .25com.genesyslab.core . . . . . . . . . . . . .24commenting on this document . . . . . . . . . 11Commons namespaces . . . . . . . . . . . .23commons packages . . . . . . . . . . . . . .23communication channel . . . . . . . . . . . .15configuration data . . . . . . . 27, 28, 31, 37, 43Configuration Layer object . . . . . . . . . . .44Configuration Platform SDK . . . . . . . . 14, 15ConfServerProtocol . . . . . . . . . . . . . .15connection . . . . . . . . . . . . . . . . . 17, 38Connection ID . . . . . . . . . . . . . . . 40, 41ConnID. . . . . . . . . . . . . . . . . . . 40, 41ControlMode . . . . . . . . . . . . . . . . . .39Create() method . . . . . . . . . . . . . . . .38Create() method (C#) . . . . . . . . . . . . .20create() method (Java). . . . . . . . . . . . .20custom media servers . . . . . . . . . . . . .14

    Ddefining statistics. . . . . . . . . . . . . . . .44deployment information . . . . . . . . . . . .25Developer Documentation CD . . . . . . . . .25DN, register . . . . . . . . . . . . . . . . . .38document

    conventions . . . . . . . . . . . . . . . . . .8errors, commenting on . . . . . . . . . . . 11version number . . . . . . . . . . . . . . . .8

    Documentation CDGenesys Developer . . . . . . . . . . . . . 25

    EEndpoint . . . . . . . . . . . . 15, 16, 29, 32, 44ESP protocol . . . . . . . . . . . . . . . . . .14Event classes . . . . . . . . . . . . . . . . .18EventACK . . . . . . . . . . . . . . . . . . .40EventAck. . . . . . . . . . . . . . 18, 21, 22, 33EventAgentLogin . . . . . . . . . . . . . . .40

  • Index

    48 Platform SDK 7.2

    EventDialing . . . . . . . . . . . . . . . .18, 40EventError . . . . . . . . . . . 21, 22, 33, 34, 40EventInvite . . . . . . . . . . . . . . . . .22, 34EventPackageInfo . . . . . . . . . . . . . . 46EventPackageOpened . . . . . . . . . . . . 46EventRinging . . . . . . . . . . . . . . . . . 41events

    unsolicited . . . . . . . . . . . . . . . . . . 22examples

    building . . . . . . . . . . . . . . . . . . . 27external service processing (ESP) . . . . . . 14

    Ffailed request . . . . . . . . . . . . . . . . . 21fields

    required . . . . . . . . . . . . . . . . . . . 21Filter . . . . . . . . . . . . . . . . . . . . . 44Form1.cs . . . . . . . . . . . . . . 28, 31, 37, 43

    GGenesys Developer Documentation CD . . . 25Genesys servers . . . . . . . . . . . . . . . 15Genesyslab.Core. . . . . . . . . . . . . . . 24

    IIMessage interface . . . . . . . 33, 35, 36, 39, 41IMessage interface (C#) . . . . . . . . . . . 21interaction

    accept . . . . . . . . . . . . . . . . . . . . 30Open Media . . . . . . . . . . . . . 22, 27, 30submitting . . . . . . . . . . . . . . . . . . 27

    InteractionServerProtocol . . . . . 15, 16, 29, 32ITX protocol . . . . . . . . . . . . . . . . . 14

    JJava . . . . . . . . . . . . . . . . . . . . . 16

    thread-handling . . . . . . . . . . . . . . . 19Java version . . . . . . . . . . . . . . . . . 26JAVA_HOME . . . . . . . . . . . . . . . . . 26JDK version . . . . . . . . . . . . . . . . . 26JVM . . . . . . . . . . . . . . . . . . . . . 26

    KKeyValueCollection. . . . . . . . . . . . . . 29

    Llibraries

    Platform SDK . . . . . . . . . . . . . . . . 26list

    media . . . . . . . . . . . . . . . . . . 31, 32login request . . . . . . . . . . . . . . . . . .20

    Mmake call. . . . . . . . . . . . . . . . . . . .41media list. . . . . . . . . . . . . . . . . . 31, 32media type . . . . . . . . . . . . . . . . . . .31MediaList property (C#) . . . . . . . . . . . .21message exchange patterns. . . . . . . . . .17Message interface (Java) . . . . . . . . . . .21message-handling . . . 18, 26, 38, 39, 43, 44, 45MessageReceiver class (Java) . . . . . . . .19messages

    receiving . . . . . . . . . . . . . . . . 17, 20sending . . . . . . . . . . . . . . . . . 17, 20

    messages return . . . . . . . . . . . . . . . .33

    Nnamespace structure . . . . . . . . . . . . .23namespaces

    Commons . . . . . . . . . . . . . . . . . . 23SDK-specific . . . . . . . . . . . . . . . . 24

    not readyagent . . . . . . . . . . . . . . . . . . . . 30

    Notification . . . . . . . . . . . . . . . . . . .45

    OOpen Media examples. . . . . . . . . . . . .27Open Media interaction . . . . . . . . 22, 27, 30Open Media Platform SDK. . . . . 14, 15, 16, 22Outbound Contact Platform SDK . . . . . 14, 15OutboundServerProtocol . . . . . . . . . . .15

    Ppackage

    statistics . . . . . . . . . . . . . . . . . . . 45package structure . . . . . . . . . . . . . . .23packages

    commons . . . . . . . . . . . . . . . . . . 23SDK-specific . . . . . . . . . . . . . . . . 24

    patternRequest/Response . . . . . . . . . . . . . 17Unsolicited Event . . . . . . . . . . . . . . 17

    patternsmessage exchange . . . . . . . . . . . . . 17

    Platform SDK libraries . . . . . . . . . . . . .26Platform SDKs

    architecture . . . . . . . . . . . . . . . . . 17

  • Index

    Developers Guide 49

    protocolCFGLIB . . . . . . . . . . . . . . . . . . . 14CMLIB . . . . . . . . . . . . . . . . . . . . 14ESP . . . . . . . . . . . . . . . . . . . . . 14ITX. . . . . . . . . . . . . . . . . . . . . . 14STATLIB . . . . . . . . . . . . . . . . . . . 14TLIB . . . . . . . . . . . . . . . . . . . . . 14

    Protocol object . . . . . . . . . . . . . . . . 29Protocol objects . . . . . . . . . . . . . . . 15

    Rready

    agent . . . . . . . . . . . . . . . . . . . . 30Receive() method . . . . . . . . . . . . . . 34Receive() method (C#) . . . . . . . . . . .21, 22receive() method (Java) . . . . . . . . . .21, 22ReceiveMessages() method (C#) . . . . . . 18receiving messages . . . . . . . . . .15, 17, 20register DN . . . . . . . . . . . . . . . . . . 38RegisterMode . . . . . . . . . . . . . . . . 38request

    failed. . . . . . . . . . . . . . . . . . . . . 21Request classes . . . . . . . . . . . . . . . 18Request() method . . . . . . . . . 29, 32, 39, 41Request() method (C#). . . . . . . . . . . . 21request() method (Java) . . . . . . . . . . . 21Request/Response pattern. . . . . . . . . . 17RequestAccept . . . . . . . . . . . . . . . . 35RequestAgentLogin . . . . . . . . 18, 22, 32, 39RequestAgentLogout. . . . . . . . . . . . . 36RequestAnswerCall . . . . . . . . . . . .18, 41RequestMakeCall . . . . . . . . . . . . . . 41RequestOpenPackage . . . . . . . . . . . . 45RequestRegisterAddress. . . . . . . . . . . 38RequestStopProcessing . . . . . . . . . . . 36RequestSubmit . . . . . . . . . . . . . . . . 29required fields . . . . . . . . . . . . . . . . 21response . . . . . . . . . . . . . . . . . . . 21return messages . . . . . . . . . . . . . . . 33

    SSDK-specific namespaces . . . . . . . . . . 24SDK-specific packages. . . . . . . . . . . . 24Send() method (C#) . . . . . . . . . . . . . 21send() method (Java) . . . . . . . . . . . . 21sending messages . . . . . . . . . . .15, 17, 20server applications . . . . . . . . . . . . . . 17serverProtocol.Open() . . . . . . . . . . . . 16setMediaList() method (Java) . . . . . . . . 21source code for examples . . . . . . . . . . 25

    statisticsubscribing to . . . . . . . . . . . . . . . . 42

    StatisticMetric . . . . . . . . . . . . . . . . .44StatisticObjectType . . . . . . . . . . . . . .44statistics

    defining . . . . . . . . . . . . . . . . . . . 44statistics example . . . . . . . . . . . . . . .42statistics object. . . . . . . . . . . . . . . . .44statistics package . . . . . . . . . . . . . . .45Statistics Platform SDK . . . . . . . . . . 14, 15StatisticsCollection . . . . . . . . . . . . . . .44STATLIB protocol . . . . . . . . . . . . . . .14StatServerProtocol . . . . . . . . . . . 15, 43, 44Subject . . . . . . . . . . . . . . . . . . . . .29submitting an interaction. . . . . . . . . . . .27subscribing to a statistic . . . . . . . . . . . .42switch

    in the contact center . . . . . . . . . . . . 37switch statement

    for checking returned events . . 22, 33, 34, 40switch statement, for checking returned events .

    22

    TTCP/IP . . . . . . . . . . . . . . . . . . . . .17thread-handling

    in C# . . . . . . . . . . . . . . . . . . . . 18in Java . . . . . . . . . . . . . . . . . . . 19

    threads. . . . 18, 22, 26, 37, 38, 39, 42, 43, 44, 45TimeProfile. . . . . . . . . . . . . . . . . . .44TimeRange . . . . . . . . . . . . . . . . . .44TLIB protocol . . . . . . . . . . . . . . . . .14TServerProtocol . . . . . . . . . . . . . . 15, 38type

    media . . . . . . . . . . . . . . . . . . . . 31typographical styles . . . . . . . . . . . . . . 8

    UUnsolicited Event pattern . . . . . . . . . . .17unsolicited events . . . . . . . . . . . . . . .22user data . . . . . . . . . . . . . . . . . . . .29

    Vversion numbering

    document . . . . . . . . . . . . . . . . . . .8Visual Studio . . . . . . . . . . . . . . . . . .26voice examples . . . . . . . . . . . . . . . .36Voice Platform SDK . . . . . . . . . . . . 13, 15

  • Index

    50 Platform SDK 7.2

    Table of ContentsPrefaceIntended AudienceUsage GuidelinesChapter SummariesDocument ConventionsRelated ResourcesMaking Comments on This Document

    About the Platform SDKsThe Platform SDKsVoiceOpen MediaOutbound ContactStatisticsConfiguration

    Getting StartedArchitecture of the Platform SDKsSending and Receiving MessagesRequests and ResponsesUnsolicited Events

    Namespace StructureCommons NamespacesSDK-Specific Namespaces

    About the Code ExamplesSetup for DevelopmentSource-Code ExamplesRequired Third-Party ToolsEnvironment SetupBuilding the ExamplesConfiguration Data

    Open Media ExamplesOpen Media Server ExampleOpen Media Client Example

    Voice ExamplesStatistics Example

    Index