summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/BoostConnectionServer.cpp10
-rw-r--r--Swiften/Network/BoostConnectionServer.h1
-rw-r--r--Swiften/Network/ConnectionServer.h2
3 files changed, 10 insertions, 3 deletions
diff --git a/Swiften/Network/BoostConnectionServer.cpp b/Swiften/Network/BoostConnectionServer.cpp
index 596761a..97c1316 100644
--- a/Swiften/Network/BoostConnectionServer.cpp
+++ b/Swiften/Network/BoostConnectionServer.cpp
@@ -21,10 +21,10 @@ void BoostConnectionServer::start() {
}
catch (const boost::system::system_error& e) {
if (e.code() == boost::asio::error::address_in_use) {
- onStopped(Conflict);
+ MainEventLoop::postEvent(boost::bind(boost::ref(onStopped), Conflict), shared_from_this());
}
else {
- onStopped(UnknownError);
+ MainEventLoop::postEvent(boost::bind(boost::ref(onStopped), UnknownError), shared_from_this());
}
}
}
@@ -39,7 +39,11 @@ void BoostConnectionServer::stop(boost::optional<Error> e) {
acceptor_->close();
acceptor_ = NULL;
}
- onStopped(e);
+ MainEventLoop::postEvent(boost::bind(boost::ref(onStopped), e), shared_from_this());
+}
+
+void BoostConnectionServer::cancelAllEvents() {
+ MainEventLoop::removeEventsFromOwner(shared_from_this());
}
void BoostConnectionServer::acceptNextConnection() {
diff --git a/Swiften/Network/BoostConnectionServer.h b/Swiften/Network/BoostConnectionServer.h
index d8e5eb4..13d87a5 100644
--- a/Swiften/Network/BoostConnectionServer.h
+++ b/Swiften/Network/BoostConnectionServer.h
@@ -20,6 +20,7 @@ namespace Swift {
void start();
void stop();
+ virtual void cancelAllEvents();
boost::signal<void (boost::optional<Error>)> onStopped;
diff --git a/Swiften/Network/ConnectionServer.h b/Swiften/Network/ConnectionServer.h
index 539367d..9300092 100644
--- a/Swiften/Network/ConnectionServer.h
+++ b/Swiften/Network/ConnectionServer.h
@@ -10,6 +10,8 @@ namespace Swift {
public:
virtual ~ConnectionServer();
+ virtual void cancelAllEvents() = 0;
+
boost::signal<void (boost::shared_ptr<Connection>)> onNewConnection;
};
}