Wiki

« Back to InAndOut

InAndOut-Csharp

Create the Application Project #

1. Open command promp

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 workspace\Etch
C:\workspace\Etch>cuae create InAndOut_CSharp}}}

3. The cuae tool will ask for the type of project that you are creating is it application or Plugin. Answer is 'application.'

Project Type? [application or plugin] application

4. Next the cuae tool will ask for the programming language Java or CSharp. Answer is 'CSharp'.

Programming language? [java or csharp] csharp

5. Next the tool will ask you for the namespace for the application, e.g. a Java program might want to use a fully qualified namespace like com.company.InAndOut_Java or something simple like InAndOut. The tool will offer you a simple namespace based on the project name. Let's accept the tools suggestion for now and use inandout_csharp. Press Enter

Project namespace? [default: inandout_csharp] 

6. The tool then asks you for the Triggering event. As our application triggers on an incoming call, select the option 4 and press Enter.

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}}}

cuae tool now generates the neccesary files for this application.

Generating:

  • application named "InAndOut_CSharp"
  • with namespace "inandout_csharp"
  • with language "csharp"
  • with trigger event "cisco.uc.cuae.legacy.CallControl.IncomingCall"
  • in location C:\workspace\Etch\

Created project "InAndOut_CSharp" in directory "C:\workspace\Etch\InAndOut_CSharp\" }}}

7. Now we need to build the application. This can be done by two ways

  • From command prompt: go to application created folder and issue the command 'msbuild'. Then you will see the files that are getting created and compiling
  • IDE: By using Microsoft Visual Studio IDE.

8. Open Microsoft Visual Studio. Select File -> Open -> Project/Solution Ctrl+Shift+O

9. Goto the application folder and select 'InAndOut_CSharp.csproj'

10. Select Build -> Build Solution

It will ask for you to give the location to save '.sln' file. Select default one and save it.

11. Above steps create required csharp source files and other files require for this solution project once build is succeeded. you will see all these in 'Solution Explorer' which is at right-hand side of VS IDE.

12. From right-hand side of VS Editor, double click on InAndOut_CSharp - > src -> inandout_csharp -> MainInAndOut_CSharpClient.cs. The file will be opened as a tab in VS Editor.

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.

For running any application we need to register application first. This is done by the fallowing code. Place this code after TODO: Insert Your Code Here

string key = server.registerApplication("InAndOut_CSharp", "Default", "<username>", "<password>");
Console.WriteLine("Application Successfully registered with key:"+key); Console.WriteLine("Press Any key to exit from the application"); Console.ReadLine();}}}

13. Open config.yaml file and enter fallowing configuration for our application and save the changes.

# CUAE Application Configuration Definition

  1. You only need to edit this file if you want to expose configuration to
  2. the administrator through cuaeadmin.
  3. This file was auto-generated from a template but will never be
  4. overwritten. You should edit this file directly if required.
  1. configuration:
  2. Indicates the name of your configuration item. It will be how you
  3. reference this configuration item from code.
  4. - name: myConfValue
  1. Controls how the visible label of the configuration value. For
  2. example, if 'name' was defined as: myConfValue, you may choose to
  3. define 'displayName' as: My Config Value. Think of it as a friendly
  4. name. This field is optional.
  5. displayName: My Config Value
  1. Defines the format of the configuration item's value. This will
  2. control how cuaeadmin renders and validates the value. Possible
  3. values for the 'format' field are: String, Bool, Number, DateTime,
  4. IP_Address, Array, HashTable, DataTable, Password.
  5. format: String
  1. A description of the configuration item that will be displayed to
  2. the administrator in cuadmin. This field is optional.
  3. description: Some description here.
  1. For configuration items that are formatted as numbers, the
  2. 'minValue' and 'maxValue' configuration items define the acceptable
  3. range of input for the item. These fields are optional.
  4. minValue:
  5. maxValue:
  1. Defines the default value of the configuration. This field is
  2. optional.
  3. defaultValue:
  1. Inidicates whether the configuration item is editable. If
  2. 'readOnly' is set to true, the administrator will not be able to
  3. edit it in cuaeadmin, but will be able to view it. The default is
  4. false, and this field is optional.
  5. readOnly:
  1. Indicates whether the configuration item is required. If required,
  2. the administrator will have to set a value before the application
  3. will run. The default is false, and this field is optional.
  4. required: false, optional, default to be false

configuration: - name: discardLeadingDigits format: Number displayName: DiscardLeadingDigits defaultValue: 1 required: True

- name: destinationDN format: String displayName: To defaultValue: NONE required: True

- name: useConfigDN format: String displayName: UseConfigDN defaultValue: false required: True

- name: useFromDN format: String displayName: UseFromDN defaultValue: false required: True }}}

14. From right-hand side of VS Editor, double click on InAndOut_CSharp - > src -> inandout_csharp -> ImplInAndOut_CSharpClient.cs. The file will be opened as a tab in VS Editor.

15. On the top of the code add the following namespace.

 using cisco.uc.cuae.legacy.types.CuaeCommon;
using System.Collections;}}}

Declare and initialize the following class variables

string destinationDN = "";
int discardLeadingDigits = 0; bool useConfigDN = false; bool useFromDN = false; string inComingCallId = ""; string mmsId = ""; string outGoingCallId = "";}}}

Insert the fallowing code after this line in the file and save changes.

TODO: Implement delegates or provide implementation of server

Hashtable incomingCallIds = new Hashtable();
Hashtable outgoingCallIds = new Hashtable(); ConfigEntry[] configs;

public override void incomingCall(string sessionId, IncomingCallOptions options) { Read the application configuration

try { ConfigEntry[] configs = server.getConfig("Default"); if (configs == null || configs.Length == 0) { return; }

try { for (int i = 0; i < configs.Length; i++) { if (configs[i].name.Equals("discardLeadingDigits")) { discardLeadingDigits = Convert.ToInt32(configs[i].GetConfigValue()); } else if (configs[i].name.Equals("destinationDN")) { destinationDN = configs[i].GetConfigValue().ToString(); } else if (configs[i].name.Equals("useConfigDN")) { useConfigDN = Convert.ToBoolean(configs[i].GetConfigValue().ToString()); } else if (configs[i].name.Equals("useFromDN")) { useFromDN = Convert.ToBoolean(configs[i].GetConfigValue().ToString()); } } } catch (Exception e) { Console.WriteLine("Exception occured while reading application config:" + e); } } catch (Exception e) { Console.WriteLine("Exception occuered while reading application configs :" + e); }

Accept callAcceptCallResult acr = server.acceptCall(sessionId, options.callId, new AcceptCallOptions());incomingCallIds.Add(sessionId, options.callId);

if (acr.returnValue != CuaeResult.SUCCESS) { Console.WriteLine("answerCall failed"); server.removeCuaeSession(sessionId); return; } /

  • If application wants to discard leading digits before dialing the destination DN
  • or if in the application specified to take the destination DN from 'from DN'
  • /

if (!useConfigDN) { if (useFromDN) { Add to support SIP Phone In / SIP Trunk out testingint num;num = Convert.ToInt32((options.from.Substring(discardLeadingDigits)));num = num + 1;destinationDN = "" + num;}else{destinationDN = destinationDN.Substring(discardLeadingDigits);}}MakeCallOptions mco = new MakeCallOptions();mco.conference = true;mco.conferenceId = "0";mco.hairpin = true;mco.mmsId = acr.mmsId;

MakeCallResult mcr = server.beginMakeCall(sessionId, destinationDN, options.from, "InAndOut", mco, null);

outgoingCallIds.Add(sessionId, mcr.callId);

if (mcr.returnValue != CuaeResult.SUCCESS) { Console.WriteLine("Failed to beginMakeCall"); server.hangup(sessionId, options.callId, null); server.removeCuaeSession(sessionId); return; } } public override void onMakeCallComplete(string sessionId, MakeCallResult results, Object state) {

Get the Out going call id

AnswerCallOptions aco = new AnswerCallOptions(); aco.conference = true; aco.conferenceId = results.conferenceId; aco.mmsId = results.mmsId;

if (results.returnValue == CuaeResult.SUCCESS) { AnswerCallResult acr = server.answerCall(sessionId, Convert.ToString(incomingCallIds[sessionId]), "InAndOut", aco); if (acr.returnValue != CuaeResult.SUCCESS) { Console.WriteLine("AnswerCall failed"); server.hangup(sessionId, results.callId, null); server.removeCuaeSession(sessionId); return; } } else { Console.WriteLine("MakeCall Failed"); Reject the dialing phoneserver.hangup(sessionId, Convert.ToString(incomingCallIds[sessionId]), null);server.removeCuaeSession(sessionId);}}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) { Get the callid's from respective Hash entriesinComingCallId = Convert.ToString(incomingCallIds[sessionId]);outGoingCallId = Convert.ToString(outgoingCallIds[sessionId]);

if (inComingCallId.Equals(options.callId)) server.hangup(sessionId, outGoingCallId, null); else server.hangup(sessionId, inComingCallId, null);

Remove hash entrie before close the sessionincomingCallIds.Remove(sessionId);outgoingCallIds.Remove(sessionId);

remove cuae session for this sessionserver.removeCuaeSession(sessionId);} }}}

16. Now we need to build the solution once again to reflect the changes that we have done so far. To do this follow step# 10.

Package the application#

1. Open command prompt and goto application directory. Issue cuae's package command

C:\> cd workspace\Etch\InAndOut_CSharp
C:\workspace\Etch\InAndOut_CSharp>cuae package Created package file "C:\workspace\Etch\InAndOut_CSharp\bin\InAndOut_CSharp.mca"}}}

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:\workspace\InAndOut_CSharp>cuae package
Created package file "C:\Development\CSHARP\workspace\InAndOut_CSharp\bin\InAndOut_CSharp.mca"

C:\workspace\InAndOut_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:\workspace\InAndOut_CSharp\bin\InAndOut_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:\workspace\InAndOut_CSharp>cuae package
Created package file "C:\Development\CSHARP\workspace\InAndOut_CSharp\bin\InAndOut_CSharp.mca"

C:\workspace\InAndOut_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:\workspace\InAndOut_CSharp\bin\InAndOut_CSharp.mca Uploading : ===========================> 100% Application ahas been installed successfully}}}

Run the application#

1. Login to application server's management console, click on Applications, Click on InAndOut_CSharp. Now configure the application like which protocol to use, To number etc...

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

C:\workspace\Etch\InAndOut_CSharp\> cd bin\debug
C:\workspace\Etch\InAndOut_CSharp\bin\Debug>InAndOut_CSharp.exe Application registered with key = e130bfe1-301f-4d50-84e6-c028eabdea23 Hit any key to exit.}}}

3. Now execute the test suite which are mentioned in the main application wiki page.

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