int main(int, char**) { char* jid = getenv("SWIFT_CLIENTTEST_JID"); if (!jid) { std::cerr << "Please set the SWIFT_CLIENTTEST_JID environment variable" << std::endl; return -1; } char* pass = getenv("SWIFT_CLIENTTEST_PASS"); if (!pass) { std::cerr << "Please set the SWIFT_CLIENTTEST_PASS environment variable" << std::endl; return -1; } client = new Swift::Client(JID(jid), std::string(pass), &networkFactories); ClientXMLTracer* tracer = new ClientXMLTracer(client); client->onConnected.connect(&handleConnected); client->setAlwaysTrustCertificates(); client->connect(); { Timer::ref timer = networkFactories.getTimerFactory()->createTimer(60000); timer->onTick.connect(boost::bind(&SimpleEventLoop::stop, &eventLoop)); timer->start(); eventLoop.run(); } delete tracer; delete client; return !rosterReceived; }
int main(int argc, char* argv[]) { if (argc < 5 || argc > 6) { std::cerr << "Usage: " << argv[0] << " <jid> [<connect_host>]<password> <recipient> <message>" << std::endl; return -1; } int argi = 1; std::string jid = argv[argi++]; std::string connectHost = ""; if (argc == 6) { connectHost = argv[argi++]; } client = new Swift::Client(JID(jid), std::string(argv[argi++]), &networkFactories); client->setAlwaysTrustCertificates(); recipient = JID(argv[argi++]); messageBody = std::string(argv[argi++]); ClientXMLTracer* tracer = new ClientXMLTracer(client); client->onConnected.connect(&handleConnected); errorConnection = client->onDisconnected.connect(&handleDisconnected); if (!connectHost.empty()) { client->connect(connectHost); } else { client->connect(); } { Timer::ref timer = networkFactories.getTimerFactory()->createTimer(30000); timer->onTick.connect(boost::bind(&SimpleEventLoop::stop, &eventLoop)); timer->start(); eventLoop.run(); } delete tracer; delete client; return exitCode; }
int main(int argc, char* argv[]) { if (argc != 5) { std::cerr << "Usage: " << argv[0] << " <jid> <password> <recipient> <file>" << std::endl; return -1; } //Log::setLogLevel(Log::debug); JID sender(argv[1]); JID recipient(argv[3]); FileSender fileSender(sender, std::string(argv[2]), recipient, boost::filesystem::path(argv[4])); fileSender.start(); { Timer::ref timer = networkFactories.getTimerFactory()->createTimer(30000); timer->onTick.connect(boost::bind(&SimpleEventLoop::stop, &eventLoop)); timer->start(); eventLoop.run(); } return exitCode; }
/* * Usage: ./MUCListAndJoin <jid> <password> <muc_domain> */ int main(int argc, char* argv[]) { int ret = 0; if (argc != 4) { cout << "Usage: ./" << argv[0] << " <jid> <password> <muc_domain>" << endl; ret = -1; } else { mucJID = JID(argv[3]); client = std::make_shared<Client>(JID(argv[1]), string(argv[2]), &networkFactories); client->setAlwaysTrustCertificates(); // Enable the following line for detailed XML logging // ClientXMLTracer* tracer = new ClientXMLTracer(client.get()); client->onConnected.connect(&handleConnected); client->onDisconnected.connect(&handleDisconnected); client->onMessageReceived.connect(&handleIncomingMessage); cout << "Connecting..." << flush; client->connect(); { Timer::ref timer = networkFactories.getTimerFactory()->createTimer(30000); timer->onTick.connect(boost::bind(&SimpleEventLoop::stop, &eventLoop)); Timer::ref disconnectTimer = networkFactories.getTimerFactory()->createTimer(25000); disconnectTimer->onTick.connect(boost::bind(&Client::disconnect, client.get())); timer->start(); disconnectTimer->start(); eventLoop.run(); } } return ret; }