summaryrefslogtreecommitdiff
path: root/cppe/demo/IceE/chat/PingThread.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2005-07-18 13:51:41 +0000
committerDwayne Boone <dwayne@zeroc.com>2005-07-18 13:51:41 +0000
commitf4535b6052eb84a26b80a075cc26a30c625760eb (patch)
treed84374f5b28be606cde131ccafa75ec9130e522d /cppe/demo/IceE/chat/PingThread.cpp
parentAdded comment (diff)
downloadice-f4535b6052eb84a26b80a075cc26a30c625760eb.tar.bz2
ice-f4535b6052eb84a26b80a075cc26a30c625760eb.tar.xz
ice-f4535b6052eb84a26b80a075cc26a30c625760eb.zip
Added ping thread
Diffstat (limited to 'cppe/demo/IceE/chat/PingThread.cpp')
-rw-r--r--cppe/demo/IceE/chat/PingThread.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/cppe/demo/IceE/chat/PingThread.cpp b/cppe/demo/IceE/chat/PingThread.cpp
new file mode 100644
index 00000000000..52e6b49cce3
--- /dev/null
+++ b/cppe/demo/IceE/chat/PingThread.cpp
@@ -0,0 +1,47 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <PingThread.h>
+
+SessionPingThread::SessionPingThread(const Glacier2::SessionPrx& session) :
+ _session(session),
+ _timeout(IceUtil::Time::seconds(20)),
+ _destroy(false)
+{
+}
+
+void
+SessionPingThread::run()
+{
+ Lock sync(*this);
+ while(!_destroy)
+ {
+ timedWait(_timeout);
+ if(_destroy)
+ {
+ break;
+ }
+ try
+ {
+ _session->ice_ping();
+ }
+ catch(const Ice::Exception&)
+ {
+ break;
+ }
+ }
+}
+
+void
+SessionPingThread::destroy()
+{
+ Lock sync(*this);
+ _destroy = true;
+ notify();
+}