Files
@ 2d304f851ce5
Branch filter:
Location: libtransport.git/tests/login/main.cpp - annotation
2d304f851ce5
1.0 KiB
text/x-c++hdr
Merge branch 'master' of https://github.com/hanzz/libtransport
b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 a9fbe73b8025 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 33587d6fc128 33587d6fc128 a9fbe73b8025 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 b74fb0544e32 | #include <iostream>
#include <boost/bind.hpp>
#include <Swiften/Swiften.h>
#include <Swiften/Client/ClientOptions.h>
using namespace Swift;
using namespace boost;
Client* client;
static void handleDisconnected(const boost::optional<ClientError> &) {
exit(1);
}
static void handleConnected() {
exit(0);
}
static void handleMessageReceived(Message::ref message) {
// Echo back the incoming message
message->setTo(message->getFrom());
message->setFrom(JID());
client->sendMessage(message);
}
int main(int, char **argv) {
SimpleEventLoop eventLoop;
BoostNetworkFactories networkFactories(&eventLoop);
client = new Client(argv[1], argv[2], &networkFactories);
client->setAlwaysTrustCertificates();
client->onConnected.connect(&handleConnected);
client->onDisconnected.connect(bind(&handleDisconnected, _1));
client->onMessageReceived.connect(bind(&handleMessageReceived, _1));
Swift::ClientOptions opt;
opt.allowPLAINWithoutTLS = true;
client->connect(opt);
eventLoop.run();
delete client;
return 0;
}
|