#include <client.h>
Inherits ClientBase.
Inheritance diagram for Client:
Public Member Functions | |
Client (const std::string &server) | |
Client (const JID &jid, const std::string &password, int port=-1) | |
Client (const std::string &username, const std::string &password, const std::string &server, const std::string &resource, int port=-1) | |
virtual | ~Client () |
void | bindResource () |
virtual const std::string | username () const |
std::string const | resource () const |
int | priority () const |
void | setUsername (const std::string &username) |
void | setResource (const std::string &resource) |
void | setInitialPriority (int priority) |
void | setAutoPresence (bool autoPresence) |
GLOOX_DEPRECATED void | setForceNonSasl (bool force=true) |
void | disableDisco () |
void | disableRoster () |
RosterManager * | rosterManager () |
Disco * | disco () |
Protected Member Functions | |
void | nonSaslLogin () |
Friends | |
class | NonSaslAuth |
class | Parser |
It supports SASL (Authentication) as well as TLS (Encryption), which can be switched on/off separately. They are used automatically if the server supports them.
To use, create a new Client instance and feed it connection credentials, either in the Constructor or afterwards using the setters. You should then register packet handlers implementing the corresponding Interfaces (ConnectionListener, PresenceHandler, MessageHandler, IqHandler, SubscriptionHandler), and call connect() to establish the connection to the server.
Simple usage example:
using namespace gloox; void TestProg::doIt() { Client* j = new Client( "user@server/resource", "password" ); j->registerPresenceHandler( this ); j->setVersion( "TestProg", "1.0" ); j->setIdentity( "client", "bot" ); j->setAutoPresence( true ); j->setInitialPriority( 5 ); j->connect(); } virtual void TestProg::presenceHandler( Stanza *stanza ) { // handle incoming presence packets here }
However, you can skip the presence handling stuff if you make use of the RosterManager.
By default, the library handles a few (incoming) IQ namespaces on the application's behalf. These include:
Definition at line 81 of file client.h.
|
Constructs a new Client which can be used for account registration only. SASL and TLS are on by default. The port will be determined by looking up SRV records. Alternatively, you can set the port explicitly by calling setPort().
Definition at line 37 of file client.cpp. References ClientBase::m_jid, and JID::setServer(). |
|
Constructs a new Client. SASL and TLS are on by default. This should be the default constructor for most use cases. The server address will be taken from the JID. The actual host will be resolved using SRV records. The domain part of the JID is used as a fallback in case no SRV record is found, or you can set the server address separately by calling setServer().
Definition at line 48 of file client.cpp. References ClientBase::jid(), ClientBase::m_jid, ClientBase::m_server, and JID::serverRaw(). |
|
Constructs a new Client. SASL and TLS are on by default. The actual host will be resolved using SRV records. The server value is used as a fallback in case no SRV record is found.
Definition at line 60 of file client.cpp. References ClientBase::m_jid, JID::setResource(), JID::setServer(), and JID::setUsername(). |
|
Virtual destructor. Definition at line 75 of file client.cpp. |
|
Use this function to re-try to bind a resource only in case you were notified about an error by means of ConnectionListener::onResourceBindError(). Definition at line 311 of file client.cpp. References Tag::addAttrib(), Tag::addChild(), Client::resource(), and ClientBase::send(). |
|
Disables automatic handling of disco queries. There is currently no way to re-enable disco query-handling.
Definition at line 433 of file client.cpp. |
|
Disables the automatic roster management. You have to keep track of incoming presence yourself if you want to have a roster. Definition at line 440 of file client.cpp. |
|
This function gives access to the
Definition at line 478 of file client.cpp. |
|
Returns the current priority.
|
|
Returns the current prepped resource.
Definition at line 145 of file client.h. Referenced by Client::bindResource(). |
|
This function gives access to the
Definition at line 473 of file client.cpp. |
|
Enables/disables the automatic sending of a presence packet upon successful authentication before the ConnectionListeners are notified. Default: off
|
|
This is a temporary hack to allow login to google talk. You must set this to true to avoid SASL PLAIN login, which fails. Google talk does not announce availability of non-SASL auth which is why it has to be enabled explicitely.
|
|
Set initial priority. Legal values: -128 <= priority <= 127
Definition at line 463 of file client.cpp. |
|
Sets the resource to use to connect to the XMPP server.
|
|
Sets the username to use to connect to the XMPP server.
|
|
Returns the current prepped username.
Implements ClientBase. Definition at line 139 of file client.h. Referenced by NonSaslAuth::doAuth(). |