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/Examples | |
parent | 0f4fad3929097dca24d1ca92b06283811661e1f4 (diff) | |
download | swift-999f19158672bd6c91fa274a9f8e968b84f8a931.zip swift-999f19158672bd6c91fa274a9f8e968b84f8a931.tar.bz2 |
Pass NetworkFactories as an explicit dependency into client.
Diffstat (limited to 'Swiften/Examples')
-rw-r--r-- | Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp | 11 | ||||
-rw-r--r-- | Swiften/Examples/SendFile/SendFile.cpp | 10 | ||||
-rw-r--r-- | Swiften/Examples/SendMessage/SendMessage.cpp | 10 |
3 files changed, 17 insertions, 14 deletions
diff --git a/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp b/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp index 9da5cdf..c090153 100644 --- a/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp +++ b/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp @@ -8,12 +8,12 @@ #include <boost/thread.hpp> #include "Swiften/Client/Client.h" -#include "Swiften/Network/BoostTimer.h" +#include "Swiften/Network/Timer.h" +#include "Swiften/Network/TimerFactory.h" +#include "Swiften/Network/BoostNetworkFactories.h" #include "Swiften/EventLoop/EventLoop.h" #include "Swiften/Client/ClientXMLTracer.h" #include "Swiften/EventLoop/SimpleEventLoop.h" -#include "Swiften/Network/BoostIOServiceThread.h" -#include "Swiften/Network/MainBoostIOServiceThread.h" #include "Swiften/Disco/GetDiscoInfoRequest.h" using namespace Swift; @@ -21,6 +21,7 @@ using namespace Swift; enum ExitCodes {OK = 0, CANNOT_CONNECT, CANNOT_AUTH, NO_RESPONSE, DISCO_ERROR}; SimpleEventLoop eventLoop; +BoostNetworkFactories networkFactories(&eventLoop); Client* client = 0; JID recipient; @@ -67,7 +68,7 @@ int main(int argc, char* argv[]) { connectHost = argv[argi++]; } - client = new Swift::Client(&eventLoop, JID(jid), String(argv[argi++])); + client = new Swift::Client(&eventLoop, &networkFactories, JID(jid), String(argv[argi++])); char* timeoutChar = argv[argi++]; int timeout = atoi(timeoutChar); timeout = (timeout ? timeout : 30) * 1000; @@ -84,7 +85,7 @@ int main(int argc, char* argv[]) { } { - BoostTimer::ref timer(BoostTimer::create(timeout, &MainBoostIOServiceThread::getInstance().getIOService(), &eventLoop)); + Timer::ref timer = networkFactories.getTimerFactory()->createTimer(timeout); timer->onTick.connect(boost::bind(&SimpleEventLoop::stop, &eventLoop)); timer->start(); diff --git a/Swiften/Examples/SendFile/SendFile.cpp b/Swiften/Examples/SendFile/SendFile.cpp index f0a2d59..630daac 100644 --- a/Swiften/Examples/SendFile/SendFile.cpp +++ b/Swiften/Examples/SendFile/SendFile.cpp @@ -9,28 +9,30 @@ #include "Swiften/Client/Client.h" #include "Swiften/Network/BoostTimer.h" +#include "Swiften/Network/TimerFactory.h" +#include "Swiften/Network/BoostNetworkFactories.h" #include "Swiften/EventLoop/EventLoop.h" #include "Swiften/Client/ClientXMLTracer.h" #include "Swiften/EventLoop/SimpleEventLoop.h" -#include "Swiften/Network/MainBoostIOServiceThread.h" #include "Swiften/FileTransfer/OutgoingFileTransfer.h" #include "Swiften/FileTransfer/FileReadBytestream.h" #include "Swiften/FileTransfer/SOCKS5BytestreamServer.h" #include "Swiften/Network/BoostConnectionServer.h" -#include "Swiften/Network/BoostIOServiceThread.h" using namespace Swift; SimpleEventLoop eventLoop; +BoostNetworkFactories networkFactories(&eventLoop); + int exitCode = 2; class FileSender { public: FileSender(const JID& jid, const String& password, const JID& recipient, const boost::filesystem::path& file, int port) : jid(jid), password(password), recipient(recipient), file(file), transfer(NULL) { - connectionServer = BoostConnectionServer::create(port, &MainBoostIOServiceThread::getInstance().getIOService(), &eventLoop); + connectionServer = BoostConnectionServer::create(port, &networkFactories.getIOServiceThread()->getIOService(), &eventLoop); socksBytestreamServer = new SOCKS5BytestreamServer(connectionServer); - client = new Swift::Client(&eventLoop, jid, password); + client = new Swift::Client(&eventLoop, &networkFactories, jid, password); client->onConnected.connect(boost::bind(&FileSender::handleConnected, this)); client->onDisconnected.connect(boost::bind(&FileSender::handleDisconnected, this, _1)); //tracer = new ClientXMLTracer(client); diff --git a/Swiften/Examples/SendMessage/SendMessage.cpp b/Swiften/Examples/SendMessage/SendMessage.cpp index 567a351..8e28dab 100644 --- a/Swiften/Examples/SendMessage/SendMessage.cpp +++ b/Swiften/Examples/SendMessage/SendMessage.cpp @@ -8,16 +8,16 @@ #include <boost/thread.hpp> #include "Swiften/Client/Client.h" -#include "Swiften/Network/BoostTimer.h" +#include "Swiften/Network/BoostNetworkFactories.h" +#include "Swiften/Network/TimerFactory.h" #include "Swiften/EventLoop/EventLoop.h" #include "Swiften/Client/ClientXMLTracer.h" #include "Swiften/EventLoop/SimpleEventLoop.h" -#include "Swiften/Network/BoostIOServiceThread.h" -#include "Swiften/Network/MainBoostIOServiceThread.h" using namespace Swift; SimpleEventLoop eventLoop; +BoostNetworkFactories networkFactories(&eventLoop); Client* client = 0; JID recipient; @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) { connectHost = argv[argi++]; } - client = new Swift::Client(&eventLoop, JID(jid), String(argv[argi++])); + client = new Swift::Client(&eventLoop, &networkFactories, JID(jid), String(argv[argi++])); client->setAlwaysTrustCertificates(); recipient = JID(argv[argi++]); @@ -73,7 +73,7 @@ int main(int argc, char* argv[]) { } { - BoostTimer::ref timer(BoostTimer::create(30000, &MainBoostIOServiceThread::getInstance().getIOService(), &eventLoop)); + Timer::ref timer = networkFactories.getTimerFactory()->createTimer(30000); timer->onTick.connect(boost::bind(&SimpleEventLoop::stop, &eventLoop)); timer->start(); |