diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-04-21 01:00:54 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-04-21 01:00:54 +0000 |
commit | 69127ef1995165a1a78027318bfb55856f5b055e (patch) | |
tree | 7057a8d6fa6196af02f368505ccc888f3404f4cb /cpp/demo/Ice/session/Client.cpp | |
parent | Optional modules in ICEE (diff) | |
download | ice-69127ef1995165a1a78027318bfb55856f5b055e.tar.bz2 ice-69127ef1995165a1a78027318bfb55856f5b055e.tar.xz ice-69127ef1995165a1a78027318bfb55856f5b055e.zip |
edits to session demo.
Diffstat (limited to 'cpp/demo/Ice/session/Client.cpp')
-rwxr-xr-x | cpp/demo/Ice/session/Client.cpp | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/cpp/demo/Ice/session/Client.cpp b/cpp/demo/Ice/session/Client.cpp index d8392ea1b91..281d8b9e05e 100755 --- a/cpp/demo/Ice/session/Client.cpp +++ b/cpp/demo/Ice/session/Client.cpp @@ -76,7 +76,6 @@ public: private: void menu(); - string trim(const string&); }; int @@ -90,18 +89,12 @@ int SessionClient::run(int argc, char* argv[]) { string name; - do + cout << "Please enter your name ==> "; + cin >> name; + if(!cin.good()) { - cout << "Please enter your name ==> "; - cin >> name; - if(!cin.good()) - { - return EXIT_FAILURE; - } - // XXX Remove. cin>>name already trims whitespace. - name = trim(name); + return EXIT_FAILURE; } - while(name.size() == 0); Ice::PropertiesPtr properties = communicator()->getProperties(); const char* proxyProperty = "SessionFactory.Proxy"; @@ -186,27 +179,29 @@ SessionClient::run(int argc, char* argv[]) } } - // XXX Wrong order. The refresher thread must be terminated - // before destroy is called, otherwise it might get - // ObjectNotExistException. + // + // The refresher thread must be terminated before destroy is + // called, otherwise it might get ObjectNotExistException. + // + refresh->terminate(); + refresh->getThreadControl().join(); + if(destroy) { session->destroy(); } } - // XXX Remove. The caller already prints excpetion. (Only the - // equivalent of a finally bock is needed here for cleanup. - catch(const Ice::Exception& ex) + catch(...) { - cerr << ex << endl; - // XXX Would have to return EXIT_FAILURE, but this point is - // moot, see comment above. + // + // The refresher thread must be terminated in the event of a + // failure. + // + refresh->terminate(); + refresh->getThreadControl().join(); + throw; } - // XXX Wrong destruction order, see comment above. - refresh->terminate(); - refresh->getThreadControl().join(); - return EXIT_SUCCESS; } @@ -222,16 +217,3 @@ SessionClient::menu() "t: exit without destroying the session\n" "?: help\n"; } - -// XXX Remove. -string -SessionClient::trim(const string& s) -{ - static const string delims = "\t\r\n "; - string::size_type last = s.find_last_not_of(delims); - if(last != string::npos) - { - return s.substr(s.find_first_not_of(delims), last+1); - } - return s; -} |