summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/StreamStack')
-rw-r--r--Swiften/StreamStack/WhitespacePingLayer.cpp15
-rw-r--r--Swiften/StreamStack/WhitespacePingLayer.h2
2 files changed, 15 insertions, 2 deletions
diff --git a/Swiften/StreamStack/WhitespacePingLayer.cpp b/Swiften/StreamStack/WhitespacePingLayer.cpp
index b10ba1a..25e4436 100644
--- a/Swiften/StreamStack/WhitespacePingLayer.cpp
+++ b/Swiften/StreamStack/WhitespacePingLayer.cpp
@@ -1,4 +1,7 @@
#include "Swiften/StreamStack/WhitespacePingLayer.h"
+
+#include "Swiften/Network/BoostIOServiceThread.h"
+#include "Swiften/Network/MainBoostIOServiceThread.h"
#include "Swiften/Network/Timer.h"
namespace Swift {
@@ -6,9 +9,9 @@ namespace Swift {
static const int TIMEOUT_MILLISECONDS = 60000;
WhitespacePingLayer::WhitespacePingLayer() {
- timer = boost::shared_ptr<Timer>(new Timer(TIMEOUT_MILLISECONDS));
+ // FIXME: Create a BoostTimerFactory.
+ timer = boost::shared_ptr<Timer>(new Timer(TIMEOUT_MILLISECONDS, &MainBoostIOServiceThread::getInstance().getIOService()));
timer->onTick.connect(boost::bind(&WhitespacePingLayer::handleTimerTick, this));
- timer->start();
}
void WhitespacePingLayer::writeData(const ByteArray& data) {
@@ -23,4 +26,12 @@ void WhitespacePingLayer::handleTimerTick() {
onWriteData(" ");
}
+void WhitespacePingLayer::setActive() {
+ timer->start();
+}
+
+void WhitespacePingLayer::setInactive() {
+ timer->stop();
+}
+
}
diff --git a/Swiften/StreamStack/WhitespacePingLayer.h b/Swiften/StreamStack/WhitespacePingLayer.h
index ed0648b..de6013b 100644
--- a/Swiften/StreamStack/WhitespacePingLayer.h
+++ b/Swiften/StreamStack/WhitespacePingLayer.h
@@ -12,6 +12,8 @@ namespace Swift {
public:
WhitespacePingLayer();
+ void setActive();
+ void setInactive();
void writeData(const ByteArray& data);
void handleDataRead(const ByteArray& data);