Messaging Application-Csharp - Wiki
Wiki
Messaging Application-Csharp
About the Application#
This application uses the Messaging Plugin. The application cannot be created if you do not have this plugin correctly created, installed, and running.
Creating the Application Project#
1. Open a Command Prompt window.
2. Navigate to the directory you want to use as your workspace. To use the CUAE command-line tool to create a new application, type the cuae create command and the name of the application project.
c:>c:> cuae create MessagingAppCSharp}}}
The tool then prompts you for additional information.
Note: Once you are more familiar with the options, you can type the full command rather than answering the prompts by using the following syntax://
cuae create -l language -m namespace -t project type [options] projectname
3. First the tool prompts you to choose between building an application or a plugin. In this example, the correct choice is application:
Project Type? [application or plugin] application
4. Next the tool prompts you to specify the programming language. In this example, the correct choice is csharp:
Programming language? [java or csharp] csharp
5. The tool asks you for the namespace for the application. A program might want to use a fully qualified namespace like com.company.messagingappcsharp or something simple like messagingappcsharp. The tool offers you a simple namespace based on the project name. Let's accept the tool's suggestion for now and use messagingappcsharp:
Project namespace? [default: messagingappcsharp] <Return>
6. Finally, the tool asks if you would like to specify a triggering event. All applications need to register against at least one triggering event. You can specify the triggering event now or wait and specify the triggering event later. You can also change the triggering event during development. Again, since we know that this application needs to be triggered on an incoming call, let's go ahead and specify the triggering event now. Select option 5:
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-9] 5 }}}
The tool now has enough information to generate the project template.
Generating:
- application named "MessagingAppCSharp"
- with namespace "messagingappcsharp"
- with language "csharp"
- with trigger event "cisco.uc.cuae.legacy.Http.GotRequest"
- in location C:\MessagingAppCSharp\
Created project "MessagingAppCSharp" in directory "C:\" }}}
Here is the whole sequence again with all of the steps together:
c:\> cuae create MessagingAppCSharpProject type? [application or plugin] application Programming language? [java or csharp] csharp Project namespace? [default: messagingappcsharp] 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-9] 5 Generating:
- application named "MessagingAppCSharp"
- with namespace "messagingappcsharp"
- with laguage "csharp"
- with trigger event "cisco.uc.cuae.legacy.Http.GotRequest"
- in location C:\MessagingAppCSharp\
Created project "MessagingAppCSharp" in directory "C:\MessagingAppCSharp\" }}}
Inspecting the Generated Project#
Let's inspect the files that were generated by the CUAE command-line tool. It created an MessagingAppCSharp directory in the directory from which you ran the cuae create command. The MessagingAppCSharp directory contains the following files and directories:
- MessagingAppCSharp.etch
- MessagingAppCSharp.properties
- MessagingAppCSharp.csproj
- cuae-resources/
- README.txt
- src/
The most important of which, for your purposes, are:
- MessagingAppCSharp.etch--CUAE application Etch service definition. Edit this file to use additional CUAE services in your project.
- MessagingAppCSharp.csproj--CSharp project file
- cuae-resources/--CUAE application resource directory.
- src/--Generated application source files.
Declaring Services#
The first step in building an Etch-based application is identifying which Cisco Unified Application Environment hosted services the application requires and then editing the .etch file to declare the names of those services into the application.
Note: Once you identify the services you need, you can familiarize yourself with them by visiting the API reference for the version of the Unified Application Environment you are using.
The following snippet is the default content of the .etch file that the CUAE command-line tool generates. We use the mixin command to declare the appropriate services.
// CUAE Application Etch Service DefinitionThis 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 messagingappcsharp
The name of your service.service MessagingAppCSharp{ 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.Http mixin cisco.uc.cuae.messaging
} }}}
Because this application will use methods in the Messaging Plugin library to retrieve/play/send messages to the Unity Connection server, we need to mixin the Messaging etch file.
mixin cisco.uc.cuae.messaging
The default etch file already has a mixin for HTTP because of the triggering event you selected when creating the application project.
mixin cisco.uc.cuae.legacy.Http
The new MessagingAppCSharp.etch file should look like this:
// CUAE Application Etch Service DefinitionThis 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 messagingappcsharp
The name of your service.service MessagingAppCSharp{ 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.Http mixin cisco.uc.cuae.messaging } }}}
Building the Application#
After declaring the services you need, you must build the application to generate source files.
1. Open a Command Prompt and navigate to the application directory.
2. Run the msbuild command to generate source files.
C:\MessagingAppCSharp\>msbuild
The following source file templates are then created in the directory src\messagingappcsharp:
- MainMessagingAppCSharpClient.cs
- ImplMessagingAppCSharpClient.cs
Writing Application Code#
This section provides instructions and code samples for writing the application logic.
Import the Project into your IDE#
1. Open Visual Studio (or another IDE of your preference).
2. Create a new CSharp project from the existing project file by selecting File -> Open -> Project/Solution and selecting the MessagingAppCSharp.csproj file from the MessagingAppCSharp directory.
MainMessagingAppClient (Registering the Application)#
This is the main class of this application. Here the application is registered with CUAE. Once the registration is done, a command line tool is launched from this class.
Code sample for Main method#
public static void Main(String[] args){ TODO: Change to correct URIstring uri = "tcp://10.89.30.177:9000?TcpConnection.reconnect_delay=4000&filter=KeepAlive&Packetizer.maxPktSize=0";
MainMessagingAppCSharpClient client = new MainMessagingAppCSharpClient();
RemoteMessagingAppCSharpServer server = MessagingAppCSharpHelper.NewServer(uri, null, client);
Connect to the serviceserver._StartAndWaitUp(4000);
String regKey = server.registerApplication("MessagingAppCSharp", "Default", "Administrator", "metreos");
Console.WriteLine("Messaging App registered with key " + regKey);
sessionId = server.addCuaeSession(regKey);
client.LaunchCmdLineTool();
server.removeCuaeSession(sessionId);
Disconnect from the serviceserver._StopAndWaitDown(4000);} }}}
Registering the application#
Before any Etch-based API calls can actually be made, we must register the application with the Cisco Unified Application Server.
Following lines of code register the application with CUAE
String regKey = server.registerApplication("MessagingAppCSharp", "Default", "Administrator", "metreos");Console.WriteLine("Messaging App registered with key " + regKey); }}}
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 URIString 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 URIString 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.
Obtaining the session Id#
We also need to get the session id from CUAE server. The session id is required in almost all calls to the Messaging plugin API. regKey is the registeration key returned by registerApplication method
sessionId = server.addCuaeSession(regKey);
Output#
When this class is run, the following is displayed on the Console.
----------------------------Sample Unity Connection App (CSharp) ---------------------------- Usage: login <Username> <Password> <UserType> getMessage playMessage <MsgId> sendMessage <FileName> <Destination> <Source> forwardMessage <MsgId> <Destination> <Source> deleteMessage <MsgId> findMessages <constraint> getMessageCount isLoggedIn logout quit Cmd:}}}
Login#
The first thing a user will do is login to the unity connection server. Following is the command for login.
Cmd: login dpotter _t3st1234 EndUser
Code Snippet for Login#
private void Login(string[] arr){
if (arr.Length != 3) { Console.WriteLine(" Correct Number of parameters are not specified for Login"); return; } if (userName != null) { Console.WriteLine("User " + userName + " is already logged in. Please logout the user" + " before trying to login an another user "); return; } string uName = arr[1]; string passwd = arr[2]; try { mailbox = server.openMailbox(sessionId, uName, uName, passwd); userName = uName; Console.WriteLine("User " + userName + " successfully logged in "); } catch (AuthenticationException e) { Console.WriteLine("Exception in Login : {0} ", e.StackTrace); } catch (UnderlyingProtocolException e) { Console.WriteLine("Exception in Login : {0} ", e.StackTrace); } catch (MessagingException e) { Console.WriteLine("Exception in Login : {0} ", e.StackTrace); } catch (Exception e) { Console.WriteLine("Exception in Login : {0} ", e.StackTrace); } } }}}
Messaging Plugin login API requires user to provide the sessionId, which is what we received when we added the cuae session. userName, password and userType is provided at command line. Valid values for UserType are SuperUser and EndUser.
Once the login is successful, the mailbox for the userName is opened.
Get Message#
----------------------------Sample Unity Connection App (CSharp) ---------------------------- Usage: login <Username> <Password> <UserType> getMessage <MsgId> playMessage <MsgId> sendMessage <FileName> <Destination> <Source> forwardMessage <MsgId> <Destination> <Source> deleteMessage <MsgId> findMessages <constraint> getMessageSize <MsgId> getMessageCount isLoggedIn logout quit Cmd:getMessage 1 }}}
getMessages gets a message depending upon the messageId you pass from the Unity Connection Server for the logged in user
Code Snippet for GetMessage#
private void GetMessage(string[] arr){ try { if (userName != null) { if(arr.Length != 2) { Console.WriteLine("Incorrect number of parameters specified for getMessage." + " Usage getMessage <messageId> "); return; } String messageId = arr[1]; Message msg = server.getMessage(sessionId, mailbox.GetId(), messageId, null);
Console.WriteLine("Message, id: " + messageId + " for user " + userName + " is from " + msg.GetFromUserName() + " to user " + userName + " sent on " + msg.GetReceivedOn() + " in state " + msg.GetMessageState() + " with subject " + msg.GetSubject() + " sent from actual number " + msg.GetFromNumber()); } else { Console.WriteLine("User not logged in"); } } catch (InvalidArgumentException e) { Console.WriteLine("Exception is " + e.StackTrace); }
catch (UnderlyingProtocolException e) { Console.WriteLine("Exception is " + e.StackTrace); } catch (MessagingException e) { Console.WriteLine("Exception is " + e.StackTrace); }
} }}}
Output#
The user will see the following on the command line console -
Message 1 for user dpotter is from UserC <userc@m-cuckoo-ft-1.cisco.com> to userdpotter sent on 30-Jul-2008 12:44:54 in state READ with subject Message from UserC sent from actual number 100000}}}
Play Message#
----------------------------Sample Unity Connection App (CSharp) ---------------------------- Usage: login <Username> <Password> <UserType> getMessage <MsgId> playMessage <MsgId> sendMessage <FileName> <Destination> <Source> forwardMessage <MsgId> <Destination> <Source> deleteMessage <MsgId> findMessages <constraint> getMessageCount isLoggedIn logout quit Cmd:playMessage 1 }}}
Play Message as the name suggests plays the voice data attached to the message. The user is expected to specify a valid message id. If the user specifies an invalid message id, the application will prompt user with a valid message id range. A good practice is to execute getMessage before playMessage. That way you will know the correct message id to specify. For example as seen in Get Message Output section (see above ), the message id are printed on the console.
e.g. Message 1 for user dpotter is from UserC <userc@m-cuckoo-ft-1.cisco.com> to user dpotter sent on 30-Jul-2008 12:44:54 in state READ with subject Message from UserC sent from actual number 100000
Code Snippet For Play Message#
private void PlayMessage(string[] arr){ try { FileStream fs; if (userName != null) { string msgId = arr[1];
string path = ".
" + msgId + ".wav"; Console.WriteLine(" The path is " + path);
if (au != null) au.Dispose();
if (File.Exists(path)) { File.Delete(path); } fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite); fs = new FileStream();
BinaryWriter w = new BinaryWriter(fs);
String transID = server.beginReadVoiceData(sessionId, mailbox.GetId(), msgId);
int transferbuffersize = 2048; for (; ; ) { sbyte[] voicedata = server.readVoiceData(sessionId, mailbox.GetId(), transID, transferbuffersize);
if (voicedata != null) { for (int j = 0; j < voicedata.Length; j++) { sbyte tdata = voicedata[j]; w.Write(tdata); } }
if (voicedata.Length < transferbuffersize) { break; }
}
w.Close(); fs.Close();
FileInfo fi = new FileInfo(path);
if (fi.Length != 0) { au = new Audio(path); au.Play(); } else { Console.WriteLine(" There is no voice data attached to this message. It may have been forwarded"); }
} else { Console.WriteLine(" User is not logged in "); } } catch (Exception e) { Console.WriteLine(" Exception is " + e.StackTrace); } } }}}
Send Message#
As the name suggests, send message allows a user to send an audio file to an another user.
Below is an example
----------------------------Sample Unity Connection App (CSharp) ---------------------------- Usage: login <Username> <Password> <UserType> getMessage <MsgId> playMessage <MsgId> sendMessage <FileName> <Destination> <Source> forwardMessage <MsgId> <Destination> <Source> deleteMessage <MsgId> findMessages <constraint> getMessageCount isLoggedIn logout quit Cmd:sendMessage c:\windows\media\ding.wav userb@m-cuckoo-ft-1.cisco.com dpotter@m-cuckoo-ft-1.cisco.com }}}
The user must specify the complete file path, destination address (userb@m-cuckoo-ft-1.cisco.com) and source address (dpotter@m-cuckoo-ft-1.cisco.com)
Code Snippet for Send Message#
Before a file can be sent to the Unity Connection server, it must be uploaded to the server. File is uploaded using uploadData API which returns back a file id. The file id is passed as a parameter in sendMessage API. Following code snippets depicts this -
private void SendMessage(string[] arr){ try { if (userName != null) { if (arr.Length != 4) { Console.WriteLine(" Correct Number of parameters are not specified for SendMessage"); return; }
string fileName = arr[1]; string destUser = arr[2]; string srcUser = arr[3];
FileStream fs = new FileStream(fileName, FileMode.Open); BinaryReader reader = new BinaryReader(fs); FileInfo info = new FileInfo(fileName); byte[] data = new byte[(int)info.Length];
reader.Read(data, 0, (int)info.Length);
string oGlobFileID = UploadData(data);
Console.WriteLine(" before send message");
int? msgID = server.sendMessage(sessionId, mailbox.GetId(), destUser, srcUser, oGlobFileID);
Console.WriteLine(" Sent message with msg id " + msgID); } else { Console.WriteLine("User is not logged in"); }
} catch (Exception e) { Console.WriteLine(" Exception in SendMessage " + e.StackTrace);
}
}
private string UploadData(byte[] oData) { int nChunkSize = 1024; int nChunks = oData.Length / nChunkSize; int nLastChunk = oData.Length - (nChunks nChunkSize);
string oGlobFileID = null; long nOffset = 0; for (int i = 0; i < nChunks; i++) { byte[] oChunkData = new byte[nChunkSize]; sbyte[] oChunkDataS = new sbyte[nChunkSize];
for (int j1 = 0; j1 < nChunkSize; j1++) { oChunkData[j1] = oData[(int)nOffset]; nOffset++; }
Buffer.BlockCopy(oChunkData, 0, oChunkDataS, 0, oChunkDataS.Length);
try { oGlobFileID = server.uploadData(sessionId, oChunkDataS, oGlobFileID); Console.WriteLine("oGlobFileID : " + oGlobFileID); } catch (Exception e1) { Console.WriteLine(" Exception is " + e1.StackTrace); return null; } }
byte[] oChunkData1 = new byte[nLastChunk]; sbyte[] oChunkData1S = new sbyte[nLastChunk]; for (int i = 0; i < nLastChunk; i++) { oChunkData1[i] = oData[(int)nOffset]; nOffset++; } Buffer.BlockCopy(oChunkData1, 0, oChunkData1S, 0, oChunkData1S.Length); try { oGlobFileID = server .uploadData(sessionId, oChunkData1S, oGlobFileID); Console.WriteLine("oGlobFileID 1: " + oGlobFileID); } catch (Exception e1) { Console.WriteLine(" Exception is " + e1.StackTrace); return null; }
return oGlobFileID;
} }}}
uploadData uploads data in chunks of 1024 bytes. This limitation is due to the maximum allowed packet size in Etch
Forward Message#
Forward Message forwards a message from one user to an another.
----------------------------Sample Unity Connection App (CSharp) ---------------------------- Usage: login <Username> <Password> <UserType> getMessage <MsgId> playMessage <MsgId> sendMessage <FileName> <Destination> <Source> forwardMessage <MsgId> <Destination> <Source> deleteMessage <MsgId> findMessages <constraint> getMessageCount isLoggedIn logout quit Cmd:forwardMessage 1 userb@m-cuckoo-ft-1.cisco.com dpotter@m-cuckoo-ft-1.cisco.com }}}
The user must specify the messageId, destination address (userb@m-cuckoo-ft-1.cisco.com) and source address (dpotter@m-cuckoo-ft-1.cisco.com)
Code Snippet for Forward Message#
public void ForwardMessage(string[] arr){ try { if (arr.Length != 4) { Console.WriteLine(" Correct Number of parameters are not specified for ForwardMessage"); return; } if (userName != null) { string msgId = arr[1]; string destUser = arr[2]; string srcUser = arr[3]; server.forwardMessage(sessionId, mailbox.GetId(), msgId, destUser, srcUser,null); } else { Console.WriteLine(" User is not logged in"); } } catch (Exception e) { Console.WriteLine(" Exception is " + e.StackTrace); } } }}}
Delete Message#
Delete Message allows user to delete a message
----------------------------Sample Unity Connection App (CSharp) ---------------------------- Usage: login <Username> <Password> <UserType> getMessage <MsgId> playMessage <MsgId> sendMessage <FileName> <Destination> <Source> forwardMessage <MsgId> <Destination> <Source> deleteMessage <MsgId> findMessages <constraint> getMessageCount isLoggedIn logout quit Cmd:deleteMessage 7 }}}
As seen in the above example, delete message requires message id to be specified.
Code Snippet for Delete Message#
public void DeleteMessage(string[] arr){ try { if (arr.Length != 2) { Console.WriteLine(" Correct Number of parameters are not specified for DeleteMessage"); return; } if (userName != null) { string msgId = arr[1]; server.deleteMessage(sessionId, mailbox.GetId(), msgId); } else { Console.WriteLine(" User is not logged in"); } } catch (Exception e) { Console.WriteLine(" Exception is " + e.StackTrace); } } }}}
Logout#
Logout logs out the current logged in user.
----------------------------Sample Unity Connection App (CSharp) ---------------------------- Usage: login <Username> <Password> <UserType> getMessage <MsgId> playMessage <MsgId> sendMessage <FileName> <Destination> <Source> forwardMessage <MsgId> <Destination> <Source> deleteMessage <MsgId> findMessages <constraint> getMessageCount isLoggedIn logout quit Cmd:logout }}}
Code Snippet for Logout#
public void Logout(string[] arr){ try { if (userName != null) { server.closeMailbox(sessionId, this.mailbox.id); Console.WriteLine("User " + userName + " is logged out "); userName = null; } else { Console.WriteLine(" User is not logged in"); } } catch (Exception e) { Console.WriteLine(" Exception is " + e.StackTrace); }
} }}}
Before logging out the user, the mailbox associated with the user must be closed.
Get Message Count#
Get Message Count gets the number of messages
----------------------------Sample Unity Connection App (CSharp) ---------------------------- Usage: login <Username> <Password> <UserType> getMessage <MsgId> playMessage <MsgId> sendMessage <FileName> <Destination> <Source> forwardMessage <MsgId> <Destination> <Source> deleteMessage <MsgId> findMessages <constraint> getMessageCount isLoggedIn logout quit Cmd:getMessageCount }}}
Code Snippet for Get Message Count#
private void GetMessageCount(string[] arr){ if (userName != null) { try { int? msgCount = server.getMessageCount(sessionId, mailbox.GetId(), "",null); Console.WriteLine(" The number of messages are " + msgCount.Value); } catch (Exception e) { Console.WriteLine("Exception is " + e.StackTrace); } } else { Console.WriteLine("User is not logged in"); } } }}}
IsLoggedIn#
isLoggedIn indicates to the user whether a user is logged in or not.
----------------------------Sample Unity Connection App (CSharp) ---------------------------- Usage: login <Username> <Password> <UserType> getMessage <MsgId> playMessage <MsgId> sendMessage <FileName> <Destination> <Source> forwardMessage <MsgId> <Destination> <Source> deleteMessage <MsgId> findMessages <constraint> getMessageSize <MsgId> getMessageCount isLoggedIn logout quit Cmd:isLoggedIn }}}
Code Snippet for IsLoggedIn#
private void IsLoggedIn(string[] arr){ try { if (server.isLoggedInAndOpen(sessionId,mailbox.id).Value) { Console.WriteLine(" User " + userName + " is logged in"); } else { Console.WriteLine(" User is not logged in"); } } catch (MessagingException e) { Console.WriteLine("Exception is " + e.StackTrace); } } }}}
Find Messages#
FindMessages allows user to find message based on a constraint. The only constraint that is currently supported is date(ddmmyyyy) and the only operator that can be used is greater than '>'. Please look at messaging.etch for constraint descriptions.
Following is an example -
----------------------------Sample Unity Connection App (CSharp) ---------------------------- Usage: login <Username> <Password> <UserType> getMessage <MsgId> playMessage <MsgId> sendMessage <FileName> <Destination> <Source> forwardMessage <MsgId> <Destination> <Source> deleteMessage <MsgId> findMessages <constraint> getMessageCount isLoggedIn logout quit Cmd:findMessages Message.receivedOn>14102008 }}}
In the above example, the user is trying to get all messages received after 14th October 2008
Code Snippet for Find Messages#
private void FindMessages(string[] arr){ try { if (userName != null) { if (arr.Length != 2) { Console.WriteLine("Incorrect number of parameters specified for findMessages." + " Usage findMessage <constraint> "); return; } String constraint = arr[1]; Console.WriteLine("The constraint is " + constraint); if(constraint.Equals("null", StringComparison.CurrentCultureIgnoreCase)) constraint = null;
Message[] msgs = server.findMessages(sessionId, mailbox.GetId(), constraint, null, 0, 100, null);
if (msgs != null) { for (int i = 0; i < msgs.Length; i++) {
Console.WriteLine("Message, id: " + msgs[i].GetId() + " for user " + userName + " is from " + msgs[i].GetFromUserName() + " to user" + userName + " sent on " + msgs[i].GetReceivedOn() + " in state " + msgs[i].GetMessageState() + " with subject " + msgs[i].GetSubject() + " sent from actual number " + msgs[i].GetFromNumber());
} } else { Console.WriteLine(" There are no messages to display"); } } else { Console.WriteLine("User not logged in"); }
} catch (InvalidArgumentException e) { Console.WriteLine("Exception in FindMessages : {0} ", e.StackTrace); } catch (UnderlyingProtocolException e) { Console.WriteLine("Exception in FindMessages : {0} ", e.StackTrace); } catch (MessagingException e) { Console.WriteLine("Exception in FindMessages : {0} ", e.StackTrace); } catch (Exception e) { Console.WriteLine("Exception in FindMessages : {0} ", e.StackTrace); }
} }}}
Output for Find Messages#
Message 4 for user dpotter is from userc@m-cuckoo-ft-1.cisco.com to user dpotter sent on Thu Sep 11 10:50:22 CDT 2008 in state READ with subject Message from UserC sent from actual number 100000Message 5 for user dpotter is from userb@m-cuckoo-ft-1.cisco.com to user dpotter sent on null in state READ with subject Forward sent from actual number 100000 Message 6 for user dpotter is from userb@m-cuckoo-ft-1.cisco.com to user dpotter sent on Thu Oct 02 09:46:36 CDT 2008 in state READ with subject SendMessage sent from actual number 100000}}}
Packaging The Test Application#
1. Execute a successful build request for your test application within your IDE.
2. To package the application, execute the "cuae package" command from a DOS command shell in the parent directory of the test application.
C:\MessagingAppCSharp>cuae packageCreated package file "C:\MessagingAppCSharp\bin\MessagingAppCSharp.mca"}}}
The following files will be added to the "\bin" sub-directory:
- MessagingAppCSharp.mca (application bundle to be uploaded into the application server)
- INSTALLER.xml - (contains the config items in config.yaml)
- MANIFEST.xml - (bundle details for the package comamnd)
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:\MessagingAppCSharp>\cuae packageCreated package file "C:\MessagingAppCSharp\bin\MessagingApp.mca"
C:\MessagingAppCSharp\>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] n Application : C:\MessagingAppCSharp\bin\MessagingAppCSharp.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:\MessagingApp\MessagingApp>cuae packageCreated package file "C:\MessagingAppCSharp\bin\MessagingAppCSharp.mca"
C:\MessagingAppCSharp\>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 : CC:\MessagingAppCSharp\bin\MessagingAppCSharp.mca Uploading : ===========================> 100% Application ahas been installed successfully}}}
Running the Application#
1. Run the class messagingappcsharp.MainMessagingAppCSharpClient to register the application.
At this point the application will remain registered and running until either you stop your application or the application loses connectivity to the Unified Application server.
2. Running the application will display the command line console shown in Section 5.2.