diff options
author | Benoit Foucher <benoit@zeroc.com> | 2005-09-23 07:52:32 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2005-09-23 07:52:32 +0000 |
commit | f992cf303ce42be7fb691e3b8ed86ce90d5f5e62 (patch) | |
tree | 75e0e331a67dbc961fc296a92985671d13e6c964 /cpp/demo/IceGrid/simple/Client.cpp | |
parent | http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=481 Added hold test. (diff) | |
download | ice-f992cf303ce42be7fb691e3b8ed86ce90d5f5e62.tar.bz2 ice-f992cf303ce42be7fb691e3b8ed86ce90d5f5e62.tar.xz ice-f992cf303ce42be7fb691e3b8ed86ce90d5f5e62.zip |
Fixes
Diffstat (limited to 'cpp/demo/IceGrid/simple/Client.cpp')
-rw-r--r-- | cpp/demo/IceGrid/simple/Client.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/cpp/demo/IceGrid/simple/Client.cpp b/cpp/demo/IceGrid/simple/Client.cpp index 284d7c6554b..d154ee888e8 100644 --- a/cpp/demo/IceGrid/simple/Client.cpp +++ b/cpp/demo/IceGrid/simple/Client.cpp @@ -8,6 +8,7 @@ // ********************************************************************** #include <Ice/Ice.h> +#include <IceGrid/Query.h> #include <Hello.h> using namespace std; @@ -51,11 +52,25 @@ HelloClient::run(int argc, char* argv[]) args = properties->parseCommandLineOptions("", args); Ice::stringSeqToArgs(args, argc, argv); + // + // First we try to connect to the object with the `hello' + // identity. If it's not registered with the registry, we seach + // for an object with the ::Demo::Hello type. + // Ice::ObjectPrx base = communicator()->stringToProxy(properties->getPropertyWithDefault("Identity", "hello")); - HelloPrx twoway = HelloPrx::checkedCast(base); + HelloPrx twoway; + try + { + twoway = HelloPrx::checkedCast(base); + } + catch(const Ice::NotRegisteredException&) + { + IceGrid::QueryPrx query = IceGrid::QueryPrx::uncheckedCast(communicator()->stringToProxy("IceGrid/Query")); + twoway = HelloPrx::checkedCast(query->findObjectByType("::Demo::Hello")); + } if(!twoway) { - cerr << argv[0] << ": invalid proxy" << endl; + cerr << argv[0] << ": couldn't find a `::Demo::Hello' object" << endl; return EXIT_FAILURE; } |