summaryrefslogtreecommitdiff
path: root/java/demo/Ice/multicast/Client.java
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2007-12-13 14:49:32 -0330
committerDwayne Boone <dwayne@zeroc.com>2007-12-13 14:49:32 -0330
commit095ce5674bfa3c48b0cabbc2e37a10c0433a46aa (patch)
tree8c66092204389e83f3e678ff0f12dae45ab567a4 /java/demo/Ice/multicast/Client.java
parent- Fixes to makemsi.py to support new directory structure. (diff)
downloadice-095ce5674bfa3c48b0cabbc2e37a10c0433a46aa.tar.bz2
ice-095ce5674bfa3c48b0cabbc2e37a10c0433a46aa.tar.xz
ice-095ce5674bfa3c48b0cabbc2e37a10c0433a46aa.zip
Added multicast demo
Diffstat (limited to 'java/demo/Ice/multicast/Client.java')
-rw-r--r--java/demo/Ice/multicast/Client.java119
1 files changed, 119 insertions, 0 deletions
diff --git a/java/demo/Ice/multicast/Client.java b/java/demo/Ice/multicast/Client.java
new file mode 100644
index 00000000000..b5ea6c11d42
--- /dev/null
+++ b/java/demo/Ice/multicast/Client.java
@@ -0,0 +1,119 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+import Demo.*;
+
+public class Client extends Ice.Application
+{
+ class ShutdownHook extends Thread
+ {
+ public void
+ run()
+ {
+ try
+ {
+ communicator().destroy();
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private static void
+ menu()
+ {
+ System.out.println(
+ "usage:\n" +
+ "t: send multicast message\n" +
+ "s: shutdown server\n" +
+ "x: exit\n" +
+ "?: help\n");
+ }
+
+ public int
+ run(String[] args)
+ {
+ if(args.length > 0)
+ {
+ System.err.println(appName() + ": too many arguments");
+ return 1;
+ }
+
+ //
+ // Since this is an interactive demo we want to clear the
+ // Application installed interrupt callback and install our
+ // own shutdown hook.
+ //
+ setInterruptHook(new ShutdownHook());
+
+ HelloPrx proxy = HelloPrxHelper.uncheckedCast(communicator().propertyToProxy("Hello.Proxy").ice_datagram());
+
+ menu();
+
+ java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
+
+ String line = null;
+ do
+ {
+ try
+ {
+ System.out.print("==> ");
+ System.out.flush();
+ line = in.readLine();
+ if(line == null)
+ {
+ break;
+ }
+ if(line.equals("t"))
+ {
+ proxy.sayHello();
+ }
+ else if(line.equals("s"))
+ {
+ proxy.shutdown();
+ }
+ else if(line.equals("x"))
+ {
+ // Nothing to do
+ }
+ else if(line.equals("?"))
+ {
+ menu();
+ }
+ else
+ {
+ System.out.println("unknown command `" + line + "'");
+ menu();
+ }
+ }
+ catch(java.io.IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ while(!line.equals("x"));
+
+ return 0;
+ }
+
+ public static void
+ main(String[] args)
+ {
+ Client app = new Client();
+ int status = app.main("Client", args, "config.client");
+ System.exit(status);
+ }
+}
+