summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2014-01-03 15:51:26 (GMT)
committerRemko Tronçon <git@el-tramo.be>2014-01-03 15:51:26 (GMT)
commit6b74536e67307aa5d21ab7b86f56dca1e653c523 (patch)
tree512c91d04bfcaba897d71d832d17a37c9bf8f984 /Swiften/Network
parenta260aa27ab2af0c71d29b3e18cfa30569d3bcd7d (diff)
downloadswift-6b74536e67307aa5d21ab7b86f56dca1e653c523.zip
swift-6b74536e67307aa5d21ab7b86f56dca1e653c523.tar.bz2
Post NAT Traversal query results to the event loop.
Change-Id: I0d61991721a5cb04b3b37784e30161531a945d61
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/PlatformNATTraversalWorker.cpp11
-rw-r--r--Swiften/Network/PlatformNATTraversalWorker.h4
2 files changed, 12 insertions, 3 deletions
diff --git a/Swiften/Network/PlatformNATTraversalWorker.cpp b/Swiften/Network/PlatformNATTraversalWorker.cpp
index 133b006..65ff577 100644
--- a/Swiften/Network/PlatformNATTraversalWorker.cpp
+++ b/Swiften/Network/PlatformNATTraversalWorker.cpp
@@ -11,6 +11,7 @@
#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Base/Log.h>
+#include <Swiften/EventLoop/EventLoop.h>
#include <Swiften/Network/NATTraversalGetPublicIPRequest.h>
#include <Swiften/Network/NATTraversalForwardPortRequest.h>
#include <Swiften/Network/NATTraversalRemovePortForwardingRequest.h>
@@ -42,6 +43,10 @@ class PlatformNATTraversalRequest : public boost::enable_shared_from_this<Platfo
return worker->getNATTraversalInterface();
}
+ EventLoop* getEventLoop() const {
+ return worker->getEventLoop();
+ }
+
virtual void runBlocking() = 0;
@@ -63,7 +68,7 @@ class PlatformNATTraversalGetPublicIPRequest : public NATTraversalGetPublicIPReq
}
virtual void runBlocking() {
- onResult(getNATTraversalInterface()->getPublicIP());
+ getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->getPublicIP()));
}
};
@@ -81,7 +86,7 @@ class PlatformNATTraversalForwardPortRequest : public NATTraversalForwardPortReq
}
virtual void runBlocking() {
- onResult(getNATTraversalInterface()->addPortForward(boost::numeric_cast<int>(localIP), boost::numeric_cast<int>(publicIP)));
+ getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->addPortForward(boost::numeric_cast<int>(localIP), boost::numeric_cast<int>(publicIP))));
}
private:
@@ -103,7 +108,7 @@ class PlatformNATTraversalRemovePortForwardingRequest : public NATTraversalRemov
}
virtual void runBlocking() {
- onResult(getNATTraversalInterface()->removePortForward(mapping));
+ getEventLoop()->postEvent(boost::bind(boost::ref(onResult), getNATTraversalInterface()->removePortForward(mapping)));
}
private:
diff --git a/Swiften/Network/PlatformNATTraversalWorker.h b/Swiften/Network/PlatformNATTraversalWorker.h
index 6148705..91b83f8 100644
--- a/Swiften/Network/PlatformNATTraversalWorker.h
+++ b/Swiften/Network/PlatformNATTraversalWorker.h
@@ -46,6 +46,10 @@ namespace Swift {
void start();
void stop();
+ EventLoop* getEventLoop() const {
+ return eventLoop;
+ }
+
private:
EventLoop* eventLoop;
bool stopRequested;