diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-09-12 02:46:32 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-09-12 02:46:32 +0000 |
commit | 759f7f34281a2c3d406ce93e52e63272a9d4beba (patch) | |
tree | 491339afc3ba74316d9d9019318836ffb6621ce8 /cpp/demo/IceBox/hello/Client.cpp | |
parent | bug fix to the icepack hello demo. (diff) | |
download | ice-759f7f34281a2c3d406ce93e52e63272a9d4beba.tar.bz2 ice-759f7f34281a2c3d406ce93e52e63272a9d4beba.tar.xz ice-759f7f34281a2c3d406ce93e52e63272a9d4beba.zip |
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=335
Diffstat (limited to 'cpp/demo/IceBox/hello/Client.cpp')
-rw-r--r-- | cpp/demo/IceBox/hello/Client.cpp | 65 |
1 files changed, 24 insertions, 41 deletions
diff --git a/cpp/demo/IceBox/hello/Client.cpp b/cpp/demo/IceBox/hello/Client.cpp index c0158a7e242..8366704983f 100644 --- a/cpp/demo/IceBox/hello/Client.cpp +++ b/cpp/demo/IceBox/hello/Client.cpp @@ -7,14 +7,32 @@ // // ********************************************************************** -#include <Ice/Ice.h> +#include <Ice/Application.h> #include <Hello.h> using namespace std; using namespace Demo; +class HelloClient : public Ice::Application +{ +public: + + virtual int run(int, char*[]); + +private: + + void menu(); +}; + +int +main(int argc, char* argv[]) +{ + HelloClient app; + return app.main(argc, argv, "config"); +} + void -menu() +HelloClient::menu() { cout << "usage:\n" @@ -31,9 +49,9 @@ menu() } int -run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +HelloClient::run(int argc, char* argv[]) { - Ice::PropertiesPtr properties = communicator->getProperties(); + Ice::PropertiesPtr properties = communicator()->getProperties(); const char* proxyProperty = "Hello.Proxy"; std::string proxy = properties->getProperty(proxyProperty); if(proxy.empty()) @@ -42,7 +60,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) return EXIT_FAILURE; } - Ice::ObjectPrx base = communicator->stringToProxy(proxy); + Ice::ObjectPrx base = communicator()->stringToProxy(proxy); HelloPrx twoway = HelloPrx::checkedCast(base->ice_twoway()->ice_timeout(-1)->ice_secure(false)); if(!twoway) { @@ -102,7 +120,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) } else if(c == 'f') { - communicator->flushBatchRequests(); + communicator()->flushBatchRequests(); } else if(c == 'T') { @@ -170,38 +188,3 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) return EXIT_SUCCESS; } - -int -main(int argc, char* argv[]) -{ - int status; - Ice::CommunicatorPtr communicator; - - try - { - Ice::PropertiesPtr properties = Ice::createProperties(); - properties->load("config"); - communicator = Ice::initializeWithProperties(argc, argv, properties); - status = run(argc, argv, communicator); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - - if(communicator) - { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - } - - return status; -} |