Wiki

« Back to GatherDigitsTortu...

GatherDigitsTortureChamber-Csharp

Requirements #

The development machine where you are creating this application should have the following installed.

1. Latest Microsoft .Net Framework.

2. Visual Studio 2005.

3. Install the CUAE Developer Tools to get the etch framework and cuae-tool.

Create the Application Project#

1. Open a Command Prompt.

2. The cuae requires at a minimum the name of the application project, the implementation language and the module name (java or csharp) to get started. If the language and or the module name are omitted the tool will prompt you for them. Lets use the cuae tool to create a new application.

 C:\> cd Wxp
C:\Wxp> cuae create GatherDigitsTortureChamber_CSharp}}}

3. The cuae tool will ask for the type of project that you are creating. Answer application.

 Project type? [application or plugin] application

4. The cuae tool will ask for the programing that we will be using for this application. Answer CSharp.

 Programming language? [java or csharp] csharp

5. The cuae tool will ask for the namespace that we will be using for this application. Just press Enter.

 Project namespace? [default: gatherdigitstorturechamber_csharp]

6. The cuae tool will ask for the application triggering event. For our application, we will be chosing the IncomingCall. Enter 4.

Available application triggering event:
0: Skip this step 1: cisco.uc.cuae.legacy.JTapi.JTapiIncomingCall 2: cisco.uc.cuae.legacy.JTapi.JTapiCallInitiated 3: cisco.uc.cuae.legacy.JTapi.JTapiCallEstablished 4: cisco.uc.cuae.legacy.CallControl.IncomingCall 5: cisco.uc.cuae.legacy.Http.GotRequest 6: cisco.uc.cuae.legacy.Presence.SubscriptionTerminated 7: cisco.uc.cuae.legacy.Presence.Notify 8: cisco.uc.cuae.legacy.TimerFacility.TimerFire Triggering event? [0-8] 4 }}}

7. Now the cuae tool will create the all the necessary files for this application.

 Generating:

  • application named "GatherDigitsTortureChamber_CSharp"
  • with namespace "gatherdigitstorturechamber_csharp"
  • with laguage "csharp"
  • with trigger event "cisco.uc.cuae.legacy.CallControl.IncomingCall"
  • in location C:\Wxp\

Created project "GatherDigitsTortureChamber_CSharp" in directory "C:\Wxp\GatherDigitsTortureChamber_CSharp\"}}}

8. Now goto C:\Wxp\GatherDigitsTortureChamber_CSharp folder. Open the file GatherDigitsTortureChamber_CSharp.etch in a notepad and add the following line "mixin cisco.uc.cuae.legacy.MediaControl" and save the file. We are adding the MediaControl mixin because the application will be playing some prompts. To play these prompts the media engine will be using TTS.

// CUAE Application Etch Service Definition
This service defines your application and the CUAE services that you use in your application.

The service module namespace, this will be translated to the namespace of the generated source code. module GatherDigitsTortureChamber_CSharp

The name of your service.service GatherDigitsTortureChamber_CSharp{ By default, you must always use the EtchBridge service. Do not remove this mixin, otherwise your application won't work.mixin cisco.uc.cuae.EtchBridge

You may add any additional service mixins that you require. For example, if you'd like to make and receive phone calls, add the following line: mixin cisco.uc.cuae.legacy.CallControl mixin cisco.uc.cuae.legacy.CallControl mixin cisco.uc.cuae.legacy.MediaControl } }}}

9. Now go to the GatherDigitsTortureChamber_CSharp directory and run the MSBuild command to generate the files for the development.

C:\Wxp>cd GatherDigitsTortureChamber_CSharp
C:\Wxp\GatherDigitsTortureChamber_CSharp\> MSBuild Microsoft (R) Build Engine Version 2.0.50727.1433 [Microsoft .NET Framework, Version 2.0.50727.1433] Copyright (C) Microsoft Corporation 2005. All rights reserved.

Build started 5/19/2008 11:05:03 AM. __________________________________________________ Project "C:\Working\temp\GatherDigitsTortureChamber_CSharp\GatherDigitsTortureCh amber_CSharp.csproj" (default targets):

Target CompileEtch: Creating directory "src\GatherDigitsTortureChamber_CSharp". Creating directory "etch-generated\etch-src". Creating directory "etch-generated\xml". "C:\Program Files\Etch\etch-0.95.0\bin\etch.bat" -q -w both,all -b xml -d "e tch-generated\xml" -I "C:\Program Files\Cisco Systems\Unified Application Enviro nment
Framework\1.0\idl" GatherDigitsTortureChamber_CSharp.etch May 19, 2008 11:05:05 AM org.apache.velocity.runtime.log.JdkLogChute log INFO: FileResourceLoader : adding path '.' warning: cannot document parameter configs of logWrite"C:\Program Files\Etch\etch-0.95.0\bin\etch.bat" -q -w client,all -b csharp -d "etch-generated\etch-src" -I "C:\Program Files\Cisco Systems\Unified Applicat ion Environment
Framework\1.0\idl" GatherDigitsTortureChamber_CSharp.etch May 19, 2008 11:05:07 AM org.apache.velocity.runtime.log.JdkLogChute log INFO: FileResourceLoader : adding path '.' warning: cannot document parameter configs of logWriteCopying file from "etch-generated\etch-src\GatherDigitsTortureChamber_CSharp\ImplGatherDigitsTortureChamber_CSharpClient.cs" to "src\gatherdigitstorturechamber_csharp\ImplGatherDigitsTortureChamber_CSharpClient.cs".Copying file from "etch-generated\etch-src\GatherDigitsTortureChamber_CSharp\MainGatherDigitsTortureChamber_CSharpClient.cs" to "src\gatherdigitstorturechamber_csharp\MainGatherDigitsTortureChamber_CSharpClient.cs".Deleting file "etch-generated\etch-src\GatherDigitsTortureChamber_CSharp\ImplGatherDigitsTortureChamber_CSharpClient.cs".Deleting file "etch-generated\etch-src\GatherDigitsTortureChamber_CSharp\MainGatherDigitsTortureChamber_CSharpClient.cs".Target PrepareForBuild:Creating directory "bin\Debug\".Creating directory "obj\Debug\".Target CoreCompile:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /checked- /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Etch\etch-0.95.0\lib\ETCH4CS.dll" /reference:................"Its a big list of files getting compiled"..............Target _CopyFilesMarkedCopyLocal:Copying file from "C:\Program Files\Etch\etch-0.95.0\lib\ETCH4CS.dll" to "bin\Debug\ETCH4CS.dll".Copying file from "C:\Program Files\Etch\etch-0.95.0\lib\ETCH4CS.pdb" to "bin\Debug\ETCH4CS.pdb".Target CopyFilesToOutputDirectory:Copying file from "obj\Debug\GatherDigitsTortureChamber_CSharp.exe" to "bin\Debug\GatherDigitsTortureChamber_CSharp.exe".GatherDigitsTortureChamber_CSharp -> C:\Working\temp\GatherDigitsTortureChamber_CSharp\bin\Debug\GatherDigitsTortureChamber_CSharp.exeCopying file from "obj\Debug\GatherDigitsTortureChamber_CSharp.pdb" to "bin\Debug\GatherDigitsTortureChamber_CSharp.pdb".

Build succeeded. 0 Warning(s) 0 Error(s)

Time Elapsed 00:00:10.06 }}}

10. Now Open Mirosoft Visual Studio 2005. Goto File->Open->Project/Solution.

11. Open the GatherDigitsTortureChamber_CSharp.csproj file.

12. Open "MainGatherDigitsTortureChamber_CSharpClient.cs" in IDE and Modify the String URI to match the IP address and port of the Cisco Unified Application Server.

URI settings vary slightly between 2.5(1) Beta 1 and more recent versions of 2.5(1), as follows:

2.5(1) and 2.5(1) Beta 2, Beta 3, Beta 4 & later releases#

// TODO Change to correct URI
String uri = "tls://appserver_ipaddress:9000?TlsConnection.authReqd=false&filter=KeepAlive &KeepAlive.Count=5&Packetizer.maxPktSize=102400&TcpTransport.reconnectDelay=4000";}}}

Note: In Beta 2, the Etch Bridge was updated to use Transport Layer Security for encryption by default. For your applications to work, you must specify TLS as the protocol in the URI and set the authReqd parameter to false. In the example above, the KeepAlive filter and Max Packet Size and Reconnect Delay parameters have also been set.

2.5(1) Beta 1#

// TODO Change to correct URI
String uri = "tcp://appserver_ipaddress:9000?&TcpConnection.reconnect_delay=4000";}}}

Note: In addition to setting the correct IP address and port for the Cisco Unfied Application Server, the Reconnect Delay parameter should be set on all connection URIs.

13. Also write the below code where the comment "TODO Insert Your Code Here" exists. Provide the administrator credential to access the system

 // TODO: Insert Your Code Here
string key = server.registerApplication ("GatherDigitsTortureChamber_CSharp", "Default", "<username>", "<password>"); Console.WriteLine("GatherDigitsTortureChamber_CSharp registered with key = " + key); Console.WriteLine( "Hit any key to exit." ); Console.Read();}}}

14. Now Open the ImplGatherDigitsTortureChamber_CSharpClient.cs. On the top of the code add the following namespace.

 using cisco.uc.cuae.legacy.types.CuaeCommon;

15. Now add the below code where the comment " TODO: Implement delegates or provide implementation of server" is written.

public override void startTx(string sessionId, StartTxOptions options)
{ }

public override void startRx(string sessionId, StartRxOptions options) { }

public override void stopTx(string sessionId, StopTxOptions options) { }

public override void remoteHangup(string sessionId, RemoteHangupOptions options) { }

public override void gotDigits(string sessionId, GotDigitsOptions options) { }

public override void incomingCall(string sessionId, IncomingCallOptions options) { Answer callAnswerCallResult acResult = server.answerCall(sessionId, options.callId, options.displayName, null);if (acResult.returnValue != CuaeResult.SUCCESS){Console.WriteLine("AnswerCall failed");server.removeCuaeSession(sessionId);return;}

Play the prompt in non-blocking fashion, pass in AnswerCallResult as state infostring sPrompt1 = "Enter 6 digits within 6 seconds or enter the pound sign to complete this call.";PlayResult prResult = server.beginPlay(sessionId, sPrompt1, acResult.connectionId, null, null, null);if (prResult.returnValue != CuaeResult.SUCCESS){Console.WriteLine("beginPlay failed");server.removeCuaeSession(sessionId);} } public override void onPlayComplete(string sessionId, PlayResult results, Object state) {

Set the values for the GatherDigitsOptions.Basically setting up the options for the various Termination Conditions GatherDigitsOptions gdOptions = new GatherDigitsOptions();

gdOptions.SetTermCondDigitPattern("#"); gdOptions.SetTermCondMaxDigits(6L); gdOptions.SetTermCondMaxTime(6000L);

GatherDigitsResult gdResult = server.beginGatherDigits(sessionId, results.connectionId, gdOptions, state);

if (gdResult.returnValue != CuaeResult.SUCCESS) { Console.WriteLine("GatherDigits failed"); server.removeCuaeSession(sessionId); } }

public override void onGatherDigitsComplete(string sessionId, GatherDigitsResult results, Object state) { Play back the digits that the user has enteredstring sPrompt1 = "You have entered " + results.digits;Console.WriteLine("gather Digits result: " + results.terminationCondition);PlayResult prResult = server.beginPlay(sessionId, sPrompt1, results.connectionId, null, null, null);if (prResult.returnValue != CuaeResult.SUCCESS)Console.WriteLine("beginPlay failed");

Console.WriteLine("endCuaeScript"); server.removeCuaeSession(sessionId); } }}}

Build the Application.#

1. To build the application. Either press "F6" or goto Build->Build Solution.

2. Now goto the command prompt

 C:\> cd Wxp\GatherDigitsTortureChamber_CSharp
C:\Wxp\GatherDigitsTortureChamber_CSharp>cuae package Created package file "C:\Wxp\GatherDigitsTortureChamber_CSharp\bin\GatherDigitsTortureChamber_CSharp.mca" }}}

3. Installing The Test Application

  • To install the test application on a CUAE server, execute the cuae install command from a DOS command shell in test application parent directory of the test application. The cuae install command varies slightly between 2.5(1) Beta 1 and Beta 2.

2.5(1) Beta 2#

You are prompted to enter an IP address, username, and password (to view the help, run the cuae install -h command). When prompted, enter Y or N to save management settings. This will save the answers to the above three questions in the properties file and remember them the next time you go to install.

Note: You are also prompted for the communications protocol (TCP or TLS). Select the protocol that is set on the Management Service. TLS is the default supported protocol. If you want to use TCP, follow the instructions in Management Service Transport Layer Security (TLS) to change the default URI of the Management Service before running these commands.

C:\Wxp\GatherDigitsTortureChamber_CSharp>cuae package
Created package file "C:\Wxp\GatherDigitsTortureChamber_CSharp\bin\GatherDigitsTortureChamber_CSharp.mca"

C:\Wxp\GatherDigitsTortureChamber_CSharp>cuae install Enter the hostname or IP address of the management service (for example: localhost, 1.1.1.1): localhost Protocol: tls Generated mgmt-service uri: tls://localhost:9001?TlsConnection.authReqd=false Enter management service login username: Entermanagement service login password: Save the amanagement settings with the project? [yes or no] no Application : C:\Wxp\GatherDigitsTortureChamber_CSharp\bin\GatherDigitsTortureChamber_CSharp.mca Uploading : ===========================> 100% Application has been installed successfully}}}

2.5(1) Beta 1#

You are prompted to enter an IP address, username, and password (to view the help, run the cuae install -h command). When prompted, enter Y or N to save management settings. This will save the answers to the above three questions in the properties file and remember them the next time you go to install.

C:\Wxp\GatherDigitsTortureChamber_CSharp>cuae package
Created package file "C:\Wxp\GatherDigitsTortureChamber_CSharp\bin\GatherDigitsTortureChamber_CSharp.mca"

C:\Wxp\GatherDigitsTortureChamber_CSharp>cuae install Enter management service uri or host/IP <for example: localhost, tcp://1.1.1.1.:4001>: Enter management service login username: Entermanagement service login password: Save the amanagement settings with the project? [YyNn] n Application : C:\Wxp\GatherDigitsTortureChamber_CSharp\bin\GatherDigitsTortureChamber_CSharp.mca Uploading : ===========================> 100% Application has been installed successfully}}}

4. To run the application. Go to the bin/debug folder of the project and run the exe created.

C:\Wxp\GatherDigitsTortureChamber_CSharp\> cd bin\debug
C:\Wxp\GatherDigitsTortureChamber_CSharp\>GatherDigitsTortureChamber_CSharp.exe GatherDigitsTortureChamber_CSharp registered with key = e130bfe1-301f-4d50-84e6-c028eabdea23 Hit any key to exit.}}}

0 Attachments
384 Views
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Comments
No comments yet. Be the first.