diff options
author | Matthew Newhook <matthew@zeroc.com> | 2009-09-09 15:11:18 -0230 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2009-09-09 15:11:18 -0230 |
commit | bbda11a7fdbcd6717029d4836e27931250d2360b (patch) | |
tree | a8ab1fe5377baa835c70e986c3313c169f53b362 /cpp/demo/Glacier2/callback/Client.cpp | |
parent | Fixed bug 4146 - re-throwing exception with fillInStackTrace (diff) | |
download | ice-bbda11a7fdbcd6717029d4836e27931250d2360b.tar.bz2 ice-bbda11a7fdbcd6717029d4836e27931250d2360b.tar.xz ice-bbda11a7fdbcd6717029d4836e27931250d2360b.zip |
http://bugzilla/bugzilla/show_bug.cgi?id=2839
In the process of fixing this bug I added ice_ping to the Glacier2
router and updated the callback demo as described. I did not update
the VB demo/Glacier2/callback, nor the windows project files.
Diffstat (limited to 'cpp/demo/Glacier2/callback/Client.cpp')
-rw-r--r-- | cpp/demo/Glacier2/callback/Client.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/cpp/demo/Glacier2/callback/Client.cpp b/cpp/demo/Glacier2/callback/Client.cpp index f40bc92247a..6df6270d6f9 100644 --- a/cpp/demo/Glacier2/callback/Client.cpp +++ b/cpp/demo/Glacier2/callback/Client.cpp @@ -7,6 +7,7 @@ // // ********************************************************************** +#include <IceUtil/IceUtil.h> #include <Ice/Ice.h> #include <Glacier2/Router.h> #include <CallbackI.h> @@ -14,6 +15,35 @@ using namespace std; using namespace Demo; +class PingTask : public IceUtil::TimerTask +{ +public: + + PingTask(const Glacier2::RouterPrx& router) : + _router(router) + { + } + + virtual void runTimerTask() + { + cout << "-> ice_ping" << endl; + try + { + _router->ice_ping(); + cout << "<- ice_ping" << endl; + } + catch(const Ice::Exception& ex) + { + cout << "<- ice_ping " << ex << endl; + // Ignore + } + } + +private: + + const Glacier2::RouterPrx _router; +}; + class CallbackClient : public Ice::Application { public: @@ -104,6 +134,9 @@ CallbackClient::run(int argc, char* argv[]) } } + IceUtil::TimerPtr timer = new IceUtil::Timer(); + timer->scheduleRepeated(new PingTask(router), IceUtil::Time::milliSeconds(router->getSessionTimeout() * 500)); + Ice::Identity callbackReceiverIdent; callbackReceiverIdent.name = "callbackReceiver"; callbackReceiverIdent.category = router->getCategoryForClient(); @@ -226,6 +259,12 @@ CallbackClient::run(int argc, char* argv[]) } while(cin.good() && c != 'x'); + // + // Destroy the timer before the router session is destroyed, + // otherwise it might get a spurious ObjectNotExistException. + // + timer->destroy(); + try { router->destroySession(); @@ -241,5 +280,6 @@ CallbackClient::run(int argc, char* argv[]) // } + return EXIT_SUCCESS; } |