diff options
author | Marc Laukien <marc@zeroc.com> | 2001-09-28 19:24:59 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-09-28 19:24:59 +0000 |
commit | 814a0caf9df6989962b8e0224022633831af6382 (patch) | |
tree | 85e2e915e187a709dd4a30db450d990a63180bd7 /cpp/demo/Ice/nested/Client.cpp | |
parent | win update (diff) | |
download | ice-814a0caf9df6989962b8e0224022633831af6382.tar.bz2 ice-814a0caf9df6989962b8e0224022633831af6382.tar.xz ice-814a0caf9df6989962b8e0224022633831af6382.zip |
initial nested demo (does not work yet)
Diffstat (limited to 'cpp/demo/Ice/nested/Client.cpp')
-rw-r--r-- | cpp/demo/Ice/nested/Client.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/cpp/demo/Ice/nested/Client.cpp b/cpp/demo/Ice/nested/Client.cpp new file mode 100644 index 00000000000..4e9bda40cd9 --- /dev/null +++ b/cpp/demo/Ice/nested/Client.cpp @@ -0,0 +1,77 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#include <Ice/Application.h> +#include <NestedI.h> + +using namespace std; +using namespace Ice; + +class NestedClient : public Application +{ +public: + + int run(int, char*[]); +}; + +int +main(int argc, char* argv[]) +{ + NestedClient app; + return app.main(argc, argv, "config"); +} + +int +NestedClient::run(int argc, char* argv[]) +{ + PropertiesPtr properties = communicator()->getProperties(); + const char* refProperty = "Nested.NestedServer"; + std::string ref = properties->getProperty(refProperty); + if (ref.empty()) + { + cerr << argv[0] << ": property `" << refProperty << "' not set" << endl; + return EXIT_FAILURE; + } + + ObjectPrx base = communicator()->stringToProxy(ref); + NestedPrx nested = NestedPrx::checkedCast(base); + if (!nested) + { + cerr << argv[0] << ": invalid object reference" << endl; + return EXIT_FAILURE; + } + + ObjectAdapterPtr adapter = communicator()->createObjectAdapter("NestedClientAdapter"); + NestedPrx self = NestedPrx::uncheckedCast(adapter->createProxy("nestedClient")); + adapter->add(new NestedI(self), "nestedClient"); + adapter->activate(); + + string s; + do + { + try + { + cout << "enter nesting level or 'x' for exit: "; + cin >> s; + int level = atoi(s.c_str()); + if (level > 0) + { + nested->nested(level, self); + } + } + catch(const LocalException& ex) + { + cerr << ex << endl; + } + } + while (cin.good() && s != "x"); + + return EXIT_SUCCESS; +} |