diff options
Diffstat (limited to 'cpp/demo/IceGrid/sessionActivation/Client.cpp')
-rw-r--r-- | cpp/demo/IceGrid/sessionActivation/Client.cpp | 170 |
1 files changed, 85 insertions, 85 deletions
diff --git a/cpp/demo/IceGrid/sessionActivation/Client.cpp b/cpp/demo/IceGrid/sessionActivation/Client.cpp index f01015892c8..8a120aef9ba 100644 --- a/cpp/demo/IceGrid/sessionActivation/Client.cpp +++ b/cpp/demo/IceGrid/sessionActivation/Client.cpp @@ -20,7 +20,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I public: SessionKeepAliveThread(const IceGrid::SessionPrx& session, long timeout) : - _session(session), + _session(session), _timeout(IceUtil::Time::seconds(timeout)), _destroy(false) { @@ -35,15 +35,15 @@ public: timedWait(_timeout); if(_destroy) { - break; - } + break; + } try { _session->keepAlive(); } catch(const Ice::Exception&) { - break; + break; } } } @@ -102,7 +102,7 @@ HelloClient::run(int argc, char* argv[]) callbackOnInterrupt(); IceGrid::RegistryPrx registry = - IceGrid::RegistryPrx::checkedCast(communicator()->stringToProxy("DemoIceGrid/Registry")); + IceGrid::RegistryPrx::checkedCast(communicator()->stringToProxy("DemoIceGrid/Registry")); if(!registry) { cerr << argv[0] << ": could not contact registry" << endl; @@ -111,93 +111,93 @@ HelloClient::run(int argc, char* argv[]) while(true) { - cout << "This demo accepts any user-id / password combination.\n"; - - string id; - cout << "user id: " << flush; - getline(cin, id); - id = trim(id); - - string password; - cout << "password: " << flush; - getline(cin, password); - password = trim(password); - - try - { - IceUtil::Mutex::Lock sync(_mutex); - _session = registry->createSession(id, password); - break; - } - catch(const IceGrid::PermissionDeniedException& ex) - { - cout << "permission denied:\n" << ex.reason << endl; - } + cout << "This demo accepts any user-id / password combination.\n"; + + string id; + cout << "user id: " << flush; + getline(cin, id); + id = trim(id); + + string password; + cout << "password: " << flush; + getline(cin, password); + password = trim(password); + + try + { + IceUtil::Mutex::Lock sync(_mutex); + _session = registry->createSession(id, password); + break; + } + catch(const IceGrid::PermissionDeniedException& ex) + { + cout << "permission denied:\n" << ex.reason << endl; + } } { - IceUtil::Mutex::Lock sync(_mutex); - _keepAlive = new SessionKeepAliveThread(_session, registry->getSessionTimeout() / 2); - _keepAlive->start(); + IceUtil::Mutex::Lock sync(_mutex); + _keepAlive = new SessionKeepAliveThread(_session, registry->getSessionTimeout() / 2); + _keepAlive->start(); } try { - HelloPrx hello = HelloPrx::checkedCast(_session->allocateObjectById(communicator()->stringToIdentity("hello"))); - - menu(); - - char c; - do - { - try - { - cout << "==> "; - cin >> c; - if(c == 't') - { - hello->sayHello(); - } - 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'); + HelloPrx hello = HelloPrx::checkedCast(_session->allocateObjectById(communicator()->stringToIdentity("hello"))); + + menu(); + + char c; + do + { + try + { + cout << "==> "; + cin >> c; + if(c == 't') + { + hello->sayHello(); + } + 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'); } catch(const IceGrid::AllocationException& ex) { - cerr << argv[0] << ": could not allocate object: " << ex.reason << endl; - status = EXIT_FAILURE; + cerr << argv[0] << ": could not allocate object: " << ex.reason << endl; + status = EXIT_FAILURE; } catch(const IceGrid::ObjectNotRegisteredException&) { - cerr << argv[0] << ": object not registered with registry" << endl; - status = EXIT_FAILURE; + cerr << argv[0] << ": object not registered with registry" << endl; + status = EXIT_FAILURE; } catch(const Ice::Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } catch(...) { - cerr << "unexpected exception" << endl; - status = EXIT_FAILURE; + cerr << "unexpected exception" << endl; + status = EXIT_FAILURE; } cleanup(); @@ -212,15 +212,15 @@ HelloClient::interruptCallback(int) try { - communicator()->destroy(); + communicator()->destroy(); } catch(const IceUtil::Exception& ex) { - cerr << appName() << ": " << ex << endl; + cerr << appName() << ": " << ex << endl; } catch(...) { - cerr << appName() << ": unknown exception" << endl; + cerr << appName() << ": unknown exception" << endl; } exit(EXIT_SUCCESS); } @@ -236,14 +236,14 @@ HelloClient::cleanup() // if(_keepAlive) { - _keepAlive->destroy(); - _keepAlive->getThreadControl().join(); - _keepAlive = 0; + _keepAlive->destroy(); + _keepAlive->getThreadControl().join(); + _keepAlive = 0; } if(_session) { - _session->destroy(); - _session = 0; + _session->destroy(); + _session = 0; } } @@ -251,10 +251,10 @@ void HelloClient::menu() { cout << - "usage:\n" - "t: send greeting\n" - "x: exit\n" - "?: help\n"; + "usage:\n" + "t: send greeting\n" + "x: exit\n" + "?: help\n"; } string |