summaryrefslogtreecommitdiff
path: root/cpp/demo/IceGrid/sessionActivation/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/demo/IceGrid/sessionActivation/Client.cpp')
-rw-r--r--cpp/demo/IceGrid/sessionActivation/Client.cpp65
1 files changed, 5 insertions, 60 deletions
diff --git a/cpp/demo/IceGrid/sessionActivation/Client.cpp b/cpp/demo/IceGrid/sessionActivation/Client.cpp
index 4a9cc760fcb..0c30c2fb51a 100644
--- a/cpp/demo/IceGrid/sessionActivation/Client.cpp
+++ b/cpp/demo/IceGrid/sessionActivation/Client.cpp
@@ -15,56 +15,6 @@
using namespace std;
using namespace Demo;
-class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex>
-{
-public:
-
- SessionKeepAliveThread(const IceGrid::SessionPrx& session, long timeout) :
- _session(session),
- _timeout(IceUtil::Time::seconds(timeout)),
- _destroy(false)
- {
- }
-
- virtual void
- run()
- {
- Lock sync(*this);
- while(!_destroy)
- {
- timedWait(_timeout);
- if(_destroy)
- {
- break;
- }
- try
- {
- _session->keepAlive();
- }
- catch(const Ice::Exception&)
- {
- break;
- }
- }
- }
-
- void
- destroy()
- {
- Lock sync(*this);
- _destroy = true;
- notify();
- }
-
-private:
-
- IceGrid::SessionPrx _session;
- const IceUtil::Time _timeout;
- bool _destroy;
-};
-
-typedef IceUtil::Handle<SessionKeepAliveThread> SessionKeepAliveThreadPtr;
-
class HelloClient : public Ice::Application
{
public:
@@ -140,8 +90,11 @@ HelloClient::run(int argc, char* argv[])
}
}
- SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread(session, registry->getSessionTimeout() / 2);
- keepAlive->start();
+ //
+ // Enable heartbeats on the session connection to maintain the
+ // connection alive even if idle.
+ //
+ session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle);
try
{
@@ -202,14 +155,6 @@ HelloClient::run(int argc, char* argv[])
status = EXIT_FAILURE;
}
- //
- // Destroy the keepAlive thread and the sesion object otherwise
- // the session will be kept allocated until the timeout occurs.
- // Destroying the session will release all allocated objects.
- //
- keepAlive->destroy();
- keepAlive->getThreadControl().join();
-
session->destroy();
return status;