summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Planas <roger.planas@isode.com>2017-05-04 13:28:53 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2017-05-05 14:15:31 (GMT)
commitf033fc54d5cd549822a3462bf0dfcc852e7b4dee (patch)
treecbc2cf68a11f5fbc25ea0627d78fadd96db49d06 /Sluift/SluiftClient.cpp
parentcfea60eda7f3ce5fa10ed92c50c19fc1ee264eb1 (diff)
downloadswift-f033fc54d5cd549822a3462bf0dfcc852e7b4dee.zip
swift-f033fc54d5cd549822a3462bf0dfcc852e7b4dee.tar.bz2
Sluift: Enable more options to be passed to connect()
There are many connection options that Sluift enables (bosh_url, tls, etc..) but only host/port were understood by connect(), the rest were meant to be set by using set_options(). This can be sometimes annoying, so to make things uniform, now connect() should accept the same options settable in set_options() Test-information: Run test to check you can pass values to connect() rather than set_options() and things worked. Change-Id: Ic79aa5c6b232ddc2ffcfc3c14aa6f31233242314
Diffstat (limited to 'Sluift/SluiftClient.cpp')
-rw-r--r--Sluift/SluiftClient.cpp9
1 files changed, 0 insertions, 9 deletions
diff --git a/Sluift/SluiftClient.cpp b/Sluift/SluiftClient.cpp
index 4680d4b..e8c43c9 100644
--- a/Sluift/SluiftClient.cpp
+++ b/Sluift/SluiftClient.cpp
@@ -27,69 +27,60 @@ SluiftClient::SluiftClient(
const JID& jid,
const std::string& password,
NetworkFactories* networkFactories,
SimpleEventLoop* eventLoop) :
networkFactories(networkFactories),
eventLoop(eventLoop),
tracer(nullptr) {
client = new Client(jid, password, networkFactories);
client->setAlwaysTrustCertificates();
client->onDisconnected.connect(boost::bind(&SluiftClient::handleDisconnected, this, _1));
client->onMessageReceived.connect(boost::bind(&SluiftClient::handleIncomingMessage, this, _1));
client->onPresenceReceived.connect(boost::bind(&SluiftClient::handleIncomingPresence, this, _1));
client->getPubSubManager()->onEvent.connect(boost::bind(&SluiftClient::handleIncomingPubSubEvent, this, _1, _2));
client->getRoster()->onInitialRosterPopulated.connect(boost::bind(&SluiftClient::handleInitialRosterPopulated, this));
client->getClientBlockListManager()->getBlockList()->onItemAdded.connect(boost::bind(&SluiftClient::handleIncomingBlockEvent, this, _1));
client->getClientBlockListManager()->getBlockList()->onItemRemoved.connect(boost::bind(&SluiftClient::handleIncomingUnblockEvent, this, _1));
}
SluiftClient::~SluiftClient() {
delete tracer;
delete client;
}
void SluiftClient::connect() {
rosterReceived = false;
blockListReceived = false;
disconnectedError = boost::optional<ClientError>();
client->connect(options);
}
-void SluiftClient::connect(const std::string& host, int port) {
- rosterReceived = false;
- blockListReceived = false;
- options.manualHostname = host;
- options.manualPort = port;
- disconnectedError = boost::optional<ClientError>();
- client->connect(options);
-}
-
void SluiftClient::setTraceEnabled(bool b) {
if (b && !tracer) {
tracer = new ClientXMLTracer(client, options.boshURL.isEmpty()? false: true);
}
else if (!b && tracer) {
delete tracer;
tracer = nullptr;
}
}
void SluiftClient::waitConnected(int timeout) {
Watchdog watchdog(timeout, networkFactories->getTimerFactory());
while (!watchdog.getTimedOut() && client->isActive() && !client->isAvailable()) {
eventLoop->runUntilEvents();
}
if (watchdog.getTimedOut()) {
client->disconnect();
throw Lua::Exception("Timeout while connecting");
}
if (disconnectedError) {
throw Lua::Exception(getErrorString(*disconnectedError));
}
}
bool SluiftClient::isConnected() const {
return client->isAvailable();
}
void SluiftClient::disconnect() {
client->disconnect();