summaryrefslogtreecommitdiff
path: root/cs/demo/Ice/hello/Client.cs
diff options
context:
space:
mode:
Diffstat (limited to 'cs/demo/Ice/hello/Client.cs')
-rw-r--r--cs/demo/Ice/hello/Client.cs320
1 files changed, 165 insertions, 155 deletions
diff --git a/cs/demo/Ice/hello/Client.cs b/cs/demo/Ice/hello/Client.cs
index 31ec2163d82..f9231860f80 100644
--- a/cs/demo/Ice/hello/Client.cs
+++ b/cs/demo/Ice/hello/Client.cs
@@ -7,218 +7,228 @@
//
// **********************************************************************
-using System;
using Demo;
+using System;
+using System.Reflection;
+
+[assembly: CLSCompliant(true)]
+
+[assembly: AssemblyTitle("IceHelloClient")]
+[assembly: AssemblyDescription("Ice hello demo client")]
+[assembly: AssemblyCompany("ZeroC, Inc.")]
-public class Client : Ice.Application
+public class Client
{
- private static void menu()
+ public class App : Ice.Application
{
- Console.Write(
- "usage:\n" +
- "t: send greeting as twoway\n" +
- "o: send greeting as oneway\n" +
- "O: send greeting as batch oneway\n" +
- "d: send greeting as datagram\n" +
- "D: send greeting as batch datagram\n" +
- "f: flush all batch requests\n" +
- "T: set a timeout\n" +
- "P: set a server delay");
- if(_haveSSL)
+ private static void menu()
{
- Console.Write("\nS: switch secure mode on/off");
+ Console.Write(
+ "usage:\n" +
+ "t: send greeting as twoway\n" +
+ "o: send greeting as oneway\n" +
+ "O: send greeting as batch oneway\n" +
+ "d: send greeting as datagram\n" +
+ "D: send greeting as batch datagram\n" +
+ "f: flush all batch requests\n" +
+ "T: set a timeout\n" +
+ "P: set a server delay");
+ if(_haveSSL)
+ {
+ Console.Write("\nS: switch secure mode on/off");
+ }
+ Console.WriteLine(
+ "\ns: shutdown server\n" +
+ "x: exit\n" +
+ "?: help\n");
}
- Console.WriteLine(
- "\ns: shutdown server\n" +
- "x: exit\n" +
- "?: help\n");
- }
- public override int run(string[] args)
- {
- if(args.Length > 0)
+ public override int run(string[] args)
{
- Console.Error.WriteLine(appName() + ": too many arguments");
- return 1;
- }
+ if(args.Length > 0)
+ {
+ Console.Error.WriteLine(appName() + ": too many arguments");
+ return 1;
+ }
- try
- {
- communicator().getPluginManager().getPlugin("IceSSL");
- _haveSSL = true;
- }
- catch(Ice.NotRegisteredException)
- {
- }
+ try
+ {
+ communicator().getPluginManager().getPlugin("IceSSL");
+ _haveSSL = true;
+ }
+ catch(Ice.NotRegisteredException)
+ {
+ }
- HelloPrx twoway = HelloPrxHelper.checkedCast(
- communicator().propertyToProxy("Hello.Proxy").ice_twoway().ice_timeout(-1).ice_secure(false));
- if(twoway == null)
- {
- Console.Error.WriteLine("invalid proxy");
- return 1;
- }
- HelloPrx oneway = (HelloPrx)twoway.ice_oneway();
- HelloPrx batchOneway = (HelloPrx)twoway.ice_batchOneway();
- HelloPrx datagram = (HelloPrx)twoway.ice_datagram();
- HelloPrx batchDatagram =(HelloPrx)twoway.ice_batchDatagram();
+ HelloPrx twoway = HelloPrxHelper.checkedCast(
+ communicator().propertyToProxy("Hello.Proxy").ice_twoway().ice_timeout(-1).ice_secure(false));
+ if(twoway == null)
+ {
+ Console.Error.WriteLine("invalid proxy");
+ return 1;
+ }
+ HelloPrx oneway = (HelloPrx)twoway.ice_oneway();
+ HelloPrx batchOneway = (HelloPrx)twoway.ice_batchOneway();
+ HelloPrx datagram = (HelloPrx)twoway.ice_datagram();
+ HelloPrx batchDatagram =(HelloPrx)twoway.ice_batchDatagram();
- bool secure = false;
- int timeout = -1;
- int delay = 0;
+ bool secure = false;
+ int timeout = -1;
+ int delay = 0;
- menu();
+ menu();
- string line = null;
- do
- {
- try
+ string line = null;
+ do
{
- Console.Out.Write("==> ");
- Console.Out.Flush();
- line = Console.In.ReadLine();
- if(line == null)
- {
- break;
- }
- if(line.Equals("t"))
- {
- twoway.sayHello(delay);
- }
- else if(line.Equals("o"))
- {
- oneway.sayHello(delay);
- }
- else if(line.Equals("O"))
+ try
{
- batchOneway.sayHello(delay);
- }
- else if(line.Equals("d"))
- {
- if(secure)
+ Console.Out.Write("==> ");
+ Console.Out.Flush();
+ line = Console.In.ReadLine();
+ if(line == null)
{
- Console.WriteLine("secure datagrams are not supported");
+ break;
}
- else
+ if(line.Equals("t"))
{
- datagram.sayHello(delay);
+ twoway.sayHello(delay);
}
- }
- else if(line.Equals("D"))
- {
- if(secure)
+ else if(line.Equals("o"))
{
- Console.WriteLine("secure datagrams are not supported");
+ oneway.sayHello(delay);
}
- else
+ else if(line.Equals("O"))
{
- batchDatagram.sayHello(delay);
+ batchOneway.sayHello(delay);
}
- }
- else if(line.Equals("f"))
- {
- communicator().flushBatchRequests();
- }
- else if(line.Equals("T"))
- {
- if(timeout == -1)
+ else if(line.Equals("d"))
{
- timeout = 2000;
+ if(secure)
+ {
+ Console.WriteLine("secure datagrams are not supported");
+ }
+ else
+ {
+ datagram.sayHello(delay);
+ }
}
- else
+ else if(line.Equals("D"))
{
- timeout = -1;
+ if(secure)
+ {
+ Console.WriteLine("secure datagrams are not supported");
+ }
+ else
+ {
+ batchDatagram.sayHello(delay);
+ }
}
-
- twoway = (HelloPrx)twoway.ice_timeout(timeout);
- oneway = (HelloPrx)oneway.ice_timeout(timeout);
- batchOneway = (HelloPrx)batchOneway.ice_timeout(timeout);
-
- if(timeout == -1)
+ else if(line.Equals("f"))
{
- Console.WriteLine("timeout is now switched off");
+ communicator().flushBatchRequests();
}
- else
+ else if(line.Equals("T"))
{
- Console.WriteLine("timeout is now set to 2000ms");
+ if(timeout == -1)
+ {
+ timeout = 2000;
+ }
+ else
+ {
+ timeout = -1;
+ }
+
+ twoway = (HelloPrx)twoway.ice_timeout(timeout);
+ oneway = (HelloPrx)oneway.ice_timeout(timeout);
+ batchOneway = (HelloPrx)batchOneway.ice_timeout(timeout);
+
+ if(timeout == -1)
+ {
+ Console.WriteLine("timeout is now switched off");
+ }
+ else
+ {
+ Console.WriteLine("timeout is now set to 2000ms");
+ }
}
- }
- else if(line.Equals("P"))
- {
- if(delay == 0)
+ else if(line.Equals("P"))
{
- delay = 2500;
+ if(delay == 0)
+ {
+ delay = 2500;
+ }
+ else
+ {
+ delay = 0;
+ }
+
+ if(delay == 0)
+ {
+ Console.WriteLine("server delay is now deactivated");
+ }
+ else
+ {
+ Console.WriteLine("server delay is now set to 2500ms");
+ }
}
- else
+ else if(_haveSSL && line.Equals("S"))
{
- delay = 0;
+ secure = !secure;
+
+ twoway = (HelloPrx)twoway.ice_secure(secure);
+ oneway = (HelloPrx)oneway.ice_secure(secure);
+ batchOneway = (HelloPrx)batchOneway.ice_secure(secure);
+ datagram = (HelloPrx)datagram.ice_secure(secure);
+ batchDatagram = (HelloPrx)batchDatagram.ice_secure(secure);
+
+ if(secure)
+ {
+ Console.WriteLine("secure mode is now on");
+ }
+ else
+ {
+ Console.WriteLine("secure mode is now off");
+ }
}
-
- if(delay == 0)
+ else if(line.Equals("s"))
{
- Console.WriteLine("server delay is now deactivated");
+ twoway.shutdown();
}
- else
+ else if(line.Equals("x"))
{
- Console.WriteLine("server delay is now set to 2500ms");
+ // Nothing to do
}
- }
- else if(_haveSSL && line.Equals("S"))
- {
- secure = !secure;
-
- twoway = (HelloPrx)twoway.ice_secure(secure);
- oneway = (HelloPrx)oneway.ice_secure(secure);
- batchOneway = (HelloPrx)batchOneway.ice_secure(secure);
- datagram = (HelloPrx)datagram.ice_secure(secure);
- batchDatagram = (HelloPrx)batchDatagram.ice_secure(secure);
-
- if(secure)
+ else if(line.Equals("?"))
{
- Console.WriteLine("secure mode is now on");
+ menu();
}
else
{
- Console.WriteLine("secure mode is now off");
+ Console.WriteLine("unknown command `" + line + "'");
+ menu();
}
}
- else if(line.Equals("s"))
- {
- twoway.shutdown();
- }
- else if(line.Equals("x"))
+ catch(System.Exception ex)
{
- // Nothing to do
- }
- else if(line.Equals("?"))
- {
- menu();
- }
- else
- {
- Console.WriteLine("unknown command `" + line + "'");
- menu();
+ Console.Error.WriteLine(ex);
}
}
- catch(System.Exception ex)
- {
- Console.Error.WriteLine(ex);
- }
+ while (!line.Equals("x"));
+
+ return 0;
}
- while (!line.Equals("x"));
-
- return 0;
+
+ private static bool _haveSSL = false;
}
public static void Main(string[] args)
{
- Client app = new Client();
+ App app = new App();
int status = app.main(args, "config.client");
if(status != 0)
{
System.Environment.Exit(status);
}
}
-
- private static bool _haveSSL = false;
}