summaryrefslogtreecommitdiff
path: root/cpp/demo/Ice/multicast/Client.cpp
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 /cpp/demo/Ice/multicast/Client.cpp
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 'cpp/demo/Ice/multicast/Client.cpp')
-rw-r--r--cpp/demo/Ice/multicast/Client.cpp120
1 files changed, 120 insertions, 0 deletions
diff --git a/cpp/demo/Ice/multicast/Client.cpp b/cpp/demo/Ice/multicast/Client.cpp
new file mode 100644
index 00000000000..be31247a8bb
--- /dev/null
+++ b/cpp/demo/Ice/multicast/Client.cpp
@@ -0,0 +1,120 @@
+// **********************************************************************
+//
+// 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.
+//
+// **********************************************************************
+
+#include <Ice/Ice.h>
+#include <Hello.h>
+
+using namespace std;
+using namespace Demo;
+
+class MulticastClient : public Ice::Application
+{
+public:
+
+ virtual int run(int, char*[]);
+ virtual void interruptCallback(int);
+
+private:
+
+ void menu();
+};
+
+int
+main(int argc, char* argv[])
+{
+ MulticastClient app;
+ return app.main(argc, argv, "config.client");
+}
+
+int
+MulticastClient::run(int argc, char* argv[])
+{
+ if(argc > 1)
+ {
+ cerr << appName() << ": too many arguments" << endl;
+ return EXIT_FAILURE;
+ }
+
+ //
+ // Since this is an interactive demo we want the custom interrupt
+ // callback to be called when the process is interrupted.
+ //
+ callbackOnInterrupt();
+
+ HelloPrx proxy = HelloPrx::uncheckedCast(communicator()->propertyToProxy("Hello.Proxy")->ice_datagram());
+
+ menu();
+
+ char c;
+ do
+ {
+ try
+ {
+ cout << "==> ";
+ cin >> c;
+ if(c == 't')
+ {
+ proxy->sayHello();
+ }
+ else if(c == 's')
+ {
+ proxy->shutdown();
+ }
+ else if(c == 'x')
+ {
+ // Nothing to do
+ }
+ else if(c == '?')
+ {
+ menu();
+ }
+ else
+ {
+ cout << "unknown command `" << c << "'" << endl;
+ menu();
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ }
+ }
+ while(cin.good() && c != 'x');
+
+ return EXIT_SUCCESS;
+}
+
+void
+MulticastClient::interruptCallback(int)
+{
+ try
+ {
+ communicator()->destroy();
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ cerr << appName() << ": " << ex << endl;
+ }
+ catch(...)
+ {
+ cerr << appName() << ": unknown exception" << endl;
+ }
+ exit(EXIT_SUCCESS);
+}
+
+void
+MulticastClient::menu()
+{
+ cout <<
+ "usage:\n"
+ "t: send multicast message\n"
+ "s: shutdown server\n"
+ "x: exit\n"
+ "?: help\n";
+}