diff options
Diffstat (limited to 'Swiften/Network/BoostConnectionServer.cpp')
-rw-r--r-- | Swiften/Network/BoostConnectionServer.cpp | 16 |
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(); |