diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-11-15 22:09:20 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-11-16 07:16:37 (GMT) |
commit | 999f19158672bd6c91fa274a9f8e968b84f8a931 (patch) | |
tree | cbcf864514c0abc71414d187f6810619bbf0fea9 /Swiften/Component/CoreComponent.cpp | |
parent | 0f4fad3929097dca24d1ca92b06283811661e1f4 (diff) | |
download | swift-contrib-999f19158672bd6c91fa274a9f8e968b84f8a931.zip swift-contrib-999f19158672bd6c91fa274a9f8e968b84f8a931.tar.bz2 |
Pass NetworkFactories as an explicit dependency into client.
Diffstat (limited to 'Swiften/Component/CoreComponent.cpp')
-rw-r--r-- | Swiften/Component/CoreComponent.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Swiften/Component/CoreComponent.cpp b/Swiften/Component/CoreComponent.cpp index 2821dd2..656f967 100644 --- a/Swiften/Component/CoreComponent.cpp +++ b/Swiften/Component/CoreComponent.cpp @@ -8,12 +8,9 @@ #include <boost/bind.hpp> -#include "Swiften/Network/MainBoostIOServiceThread.h" -#include "Swiften/Network/BoostIOServiceThread.h" #include "Swiften/Component/ComponentSession.h" #include "Swiften/Network/Connector.h" -#include "Swiften/Network/BoostConnectionFactory.h" -#include "Swiften/Network/BoostTimerFactory.h" +#include "Swiften/Network/NetworkFactories.h" #include "Swiften/TLS/PKCS12Certificate.h" #include "Swiften/Session/BasicSessionStream.h" #include "Swiften/Queries/IQRouter.h" @@ -22,7 +19,7 @@ namespace Swift { -CoreComponent::CoreComponent(EventLoop* eventLoop, const JID& jid, const String& secret) : eventLoop(eventLoop), resolver_(eventLoop), jid_(jid), secret_(secret), disconnectRequested_(false) { +CoreComponent::CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret) : eventLoop(eventLoop), networkFactories(networkFactories), resolver_(eventLoop), jid_(jid), secret_(secret), disconnectRequested_(false) { stanzaChannel_ = new ComponentSessionStanzaChannel(); stanzaChannel_->onMessageReceived.connect(boost::ref(onMessageReceived)); stanzaChannel_->onPresenceReceived.connect(boost::ref(onPresenceReceived)); @@ -30,16 +27,12 @@ CoreComponent::CoreComponent(EventLoop* eventLoop, const JID& jid, const String& iqRouter_ = new IQRouter(stanzaChannel_); iqRouter_->setFrom(jid); - connectionFactory_ = new BoostConnectionFactory(&MainBoostIOServiceThread::getInstance().getIOService(), eventLoop); - timerFactory_ = new BoostTimerFactory(&MainBoostIOServiceThread::getInstance().getIOService(), eventLoop); } CoreComponent::~CoreComponent() { if (session_ || connection_) { std::cerr << "Warning: Component not disconnected properly" << std::endl; } - delete timerFactory_; - delete connectionFactory_; delete iqRouter_; stanzaChannel_->onAvailableChanged.disconnect(boost::bind(&CoreComponent::handleStanzaChannelAvailableChanged, this, _1)); @@ -50,7 +43,7 @@ CoreComponent::~CoreComponent() { void CoreComponent::connect(const String& host, int port) { assert(!connector_); - connector_ = ComponentConnector::create(host, port, &resolver_, connectionFactory_, timerFactory_); + connector_ = ComponentConnector::create(host, port, &resolver_, networkFactories->getConnectionFactory(), networkFactories->getTimerFactory()); connector_->onConnectFinished.connect(boost::bind(&CoreComponent::handleConnectorFinished, this, _1)); connector_->setTimeoutMilliseconds(60*1000); connector_->start(); @@ -69,7 +62,7 @@ void CoreComponent::handleConnectorFinished(boost::shared_ptr<Connection> connec connection_ = connection; assert(!sessionStream_); - sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ComponentStreamType, connection_, &payloadParserFactories_, &payloadSerializers_, NULL, timerFactory_)); + sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ComponentStreamType, connection_, &payloadParserFactories_, &payloadSerializers_, NULL, networkFactories->getTimerFactory())); sessionStream_->onDataRead.connect(boost::bind(&CoreComponent::handleDataRead, this, _1)); sessionStream_->onDataWritten.connect(boost::bind(&CoreComponent::handleDataWritten, this, _1)); sessionStream_->initialize(); |