Example: example_0_connected
This example just connects to the xmpp server. And starts receiving presences (updates) from the server. After running this example, you can see this user online, if it's added in your roster (friends list). Logging type has been set to stdout. You can see the progress on the command line. This example is also available with the source code in the example directory.
#include <QtCore/QCoreApplication>
#include "QXmppClient.h"
#include "QXmppLogger.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
Example: example_1_echoClient
This is a very simple bot which echoes the message sent to it. Run this example, send it a message from a friend of this bot. You will receive the message back. This example shows how to receive and send messages. This example is also available with the source code in the example directory.
#include "QXmppClient.h"
{
Q_OBJECT
public:
echoClient(QObject *parent = 0);
~echoClient();
public slots:
};
}}}
#include "echoClient.h"
#include "QXmppMessage.h"
echoClient::echoClient(QObject *parent)
{
bool check = connect(
this, SIGNAL(messageReceived(
const QXmppMessage&)),
Q_ASSERT(check);
}
echoClient::~echoClient()
{
}
void echoClient::messageReceived(
const QXmppMessage& message)
{
QString from = message.getFrom();
QString msg = message.getBody();
}
}}}
#include <QtCore/QCoreApplication>
#include "echoClient.h"
#include "QXmppLogger.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
echoClient client;
client.connectToServer("qxmpp.test1@gmail.com", "qxmpp123");
return a.exec();
}