summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Examples')
-rw-r--r--Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp11
-rw-r--r--Swiften/Examples/SendFile/SendFile.cpp10
-rw-r--r--Swiften/Examples/SendMessage/SendMessage.cpp10
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();