summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-27 19:06:56 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-27 19:07:55 (GMT)
commit6810a2896f27e7ee07aee847f5e8dbccd1f6ec89 (patch)
treef7ea87f030e57cb4494a4f897506fb18fc3d2241 /Swiften/Network/BoostConnectionServer.cpp
parenta7da393cfc807048d320ddba8a1c7d24ef23a46e (diff)
downloadswift-contrib-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.zip
swift-contrib-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.tar.bz2
Remove MainEventLoop singleton.
The event loop now needs to be explicitly passed to clients using it.
Diffstat (limited to 'Swiften/Network/BoostConnectionServer.cpp')
-rw-r--r--Swiften/Network/BoostConnectionServer.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/Swiften/Network/BoostConnectionServer.cpp b/Swiften/Network/BoostConnectionServer.cpp
index 03ae19c..839c990 100644
--- a/Swiften/Network/BoostConnectionServer.cpp
+++ b/Swiften/Network/BoostConnectionServer.cpp
@@ -9,11 +9,11 @@
#include <boost/bind.hpp>
#include <boost/system/system_error.hpp>
-#include "Swiften/EventLoop/MainEventLoop.h"
+#include "Swiften/EventLoop/EventLoop.h"
namespace Swift {
-BoostConnectionServer::BoostConnectionServer(int port, boost::asio::io_service* ioService) : port_(port), ioService_(ioService), acceptor_(NULL) {
+BoostConnectionServer::BoostConnectionServer(int port, boost::asio::io_service* ioService, EventLoop* eventLoop) : port_(port), ioService_(ioService), eventLoop(eventLoop), acceptor_(NULL) {
}
@@ -27,10 +27,10 @@ void BoostConnectionServer::start() {
}
catch (const boost::system::system_error& e) {
if (e.code() == boost::asio::error::address_in_use) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onStopped), Conflict), shared_from_this());
+ eventLoop->postEvent(boost::bind(boost::ref(onStopped), Conflict), shared_from_this());
}
else {
- MainEventLoop::postEvent(boost::bind(boost::ref(onStopped), UnknownError), shared_from_this());
+ eventLoop->postEvent(boost::bind(boost::ref(onStopped), UnknownError), shared_from_this());
}
}
}
@@ -46,24 +46,24 @@ void BoostConnectionServer::stop(boost::optional<Error> e) {
delete acceptor_;
acceptor_ = NULL;
}
- MainEventLoop::postEvent(boost::bind(boost::ref(onStopped), e), shared_from_this());
+ eventLoop->postEvent(boost::bind(boost::ref(onStopped), e), shared_from_this());
}
void BoostConnectionServer::acceptNextConnection() {
- BoostConnection::ref newConnection(BoostConnection::create(&acceptor_->io_service()));
+ BoostConnection::ref newConnection(BoostConnection::create(&acceptor_->io_service(), eventLoop));
acceptor_->async_accept(newConnection->getSocket(),
boost::bind(&BoostConnectionServer::handleAccept, shared_from_this(), newConnection, boost::asio::placeholders::error));
}
void BoostConnectionServer::handleAccept(boost::shared_ptr<BoostConnection> newConnection, const boost::system::error_code& error) {
if (error) {
- MainEventLoop::postEvent(
+ eventLoop->postEvent(
boost::bind(
&BoostConnectionServer::stop, shared_from_this(), UnknownError),
shared_from_this());
}
else {
- MainEventLoop::postEvent(
+ eventLoop->postEvent(
boost::bind(boost::ref(onNewConnection), newConnection),
shared_from_this());
newConnection->listen();