summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp')
-rw-r--r--Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp b/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp
index 216d16d..1aaebac 100644
--- a/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp
+++ b/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp
@@ -33,88 +33,88 @@ static JID mucJID;
static JID roomJID;
static void joinMUC() {
- cout << "Joining " << roomJID.toString() << endl;
+ cout << "Joining " << roomJID.toString() << endl;
- muc = client->getMUCManager()->createMUC(roomJID);
- muc->joinAs("SwiftExample");
+ muc = client->getMUCManager()->createMUC(roomJID);
+ muc->joinAs("SwiftExample");
}
static void handleRoomsItemsResponse(boost::shared_ptr<DiscoItems> items, ErrorPayload::ref error) {
- if (error) {
- cout << "Error fetching list of rooms." << endl;
- return;
- }
-
- int roomCount = 0;
- cout << "List of rooms at " << mucJID.toString() << endl;
- foreach (DiscoItems::Item item, items->getItems()) {
- roomCount++;
- cout << "\t" << roomCount << ". " << item.getJID().getNode() << " - " << item.getName() << std::endl;
- if (roomCount == 1) {
- roomJID = item.getJID();
- }
- }
- cout << endl;
- joinMUC();
+ if (error) {
+ cout << "Error fetching list of rooms." << endl;
+ return;
+ }
+
+ int roomCount = 0;
+ cout << "List of rooms at " << mucJID.toString() << endl;
+ foreach (DiscoItems::Item item, items->getItems()) {
+ roomCount++;
+ cout << "\t" << roomCount << ". " << item.getJID().getNode() << " - " << item.getName() << std::endl;
+ if (roomCount == 1) {
+ roomJID = item.getJID();
+ }
+ }
+ cout << endl;
+ joinMUC();
}
static void handleConnected() {
- cout << "Connected." << endl;
- // search for MUC rooms
+ cout << "Connected." << endl;
+ // search for MUC rooms
- GetDiscoItemsRequest::ref discoItemsRequest = GetDiscoItemsRequest::create(mucJID, client->getIQRouter());
- discoItemsRequest->onResponse.connect(&handleRoomsItemsResponse);
+ GetDiscoItemsRequest::ref discoItemsRequest = GetDiscoItemsRequest::create(mucJID, client->getIQRouter());
+ discoItemsRequest->onResponse.connect(&handleRoomsItemsResponse);
- cout << "Request list of rooms." << endl;
- discoItemsRequest->send();
+ cout << "Request list of rooms." << endl;
+ discoItemsRequest->send();
}
static void handleDisconnected(const boost::optional<ClientError>&) {
- cout << "Disconnected." << endl;
+ cout << "Disconnected." << endl;
}
static void handleIncomingMessage(boost::shared_ptr<Message> message) {
- if (message->getFrom().toBare() == roomJID) {
- cout << "[ " << roomJID << " ] " << message->getFrom().getResource() << ": " << message->getBody().get_value_or("") << endl;
- }
+ if (message->getFrom().toBare() == roomJID) {
+ cout << "[ " << roomJID << " ] " << message->getFrom().getResource() << ": " << message->getBody().get_value_or("") << endl;
+ }
}
/*
* 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 = boost::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;
+ int ret = 0;
+
+ if (argc != 4) {
+ cout << "Usage: ./" << argv[0] << " <jid> <password> <muc_domain>" << endl;
+ ret = -1;
+ }
+ else {
+ mucJID = JID(argv[3]);
+ client = boost::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;
}