diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-09-11 13:46:08 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-09-11 14:02:39 (GMT) |
commit | 1b47266d6b955fb533b4c272b4bcc58693078a1a (patch) | |
tree | dd52b86408a03308c84c33674989d2d75af58893 /Swiften/StreamStack | |
parent | 5e235d01612b2544fe02cc34816cd6e925ed564f (diff) | |
download | swift-contrib-1b47266d6b955fb533b4c272b4bcc58693078a1a.zip swift-contrib-1b47266d6b955fb533b4c272b4bcc58693078a1a.tar.bz2 |
Disable WhitespacePingLayer on disconnect + Timer refactoring.
Timer now no longer runs in its own thread, but in the main Boost
IOService thread.
Diffstat (limited to 'Swiften/StreamStack')
-rw-r--r-- | Swiften/StreamStack/WhitespacePingLayer.cpp | 15 | ||||
-rw-r--r-- | Swiften/StreamStack/WhitespacePingLayer.h | 2 |
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); |