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();
}
Main class for starting and managing connections to XMPP servers.
Definition QXmppClient.h:62
void connectToServer(const QXmppConfiguration &, const QXmppPresence &initialPresence=QXmppPresence())
Definition QXmppClient.cpp:454
void setLoggingType(QXmppLogger::LoggingType type)
Sets the handler for logging messages.
Definition QXmppLogger.cpp:139
@ StdoutLogging
Log messages are written to the standard output.
Definition QXmppLogger.h:45
static QXmppLogger * getLogger()
Definition QXmppLogger.cpp:124
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:
};
}}}
void messageReceived(const QXmppMessage &message)
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:64
#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();
}