Public Member Functions | Public Attributes | Protected Member Functions

Swift::CoreClient Class Reference

The central class for communicating with an XMPP server. More...

Inheritance diagram for Swift::CoreClient:
Collaboration diagram for Swift::CoreClient:

List of all members.

Public Member Functions

 CoreClient (const JID &jid, const SafeByteArray &password, NetworkFactories *networkFactories)
 Constructs a client for the given JID with the given password.
 ~CoreClient ()
void setCertificate (CertificateWithKey::ref certificate)
 Set a client certificate to use for strong authentication with the server.
void connect (const ClientOptions &=ClientOptions())
 Connects the client to the server.
void disconnect ()
 Disconnects the client from the server.
void sendMessage (boost::shared_ptr< Message >)
 Sends a message.
void sendPresence (boost::shared_ptr< Presence >)
 Sends a presence stanza.
void sendData (const std::string &data)
 Sends raw, unchecked data.
IQRoutergetIQRouter () const
 Returns the IQ router for this client.
bool isAvailable () const
 Checks whether the client is connected to the server, and stanzas can be sent.
bool isActive () const
 Checks whether the client is active.
const JIDgetJID () const
 Returns the JID of the client.
bool getStreamManagementEnabled () const
 Checks whether stream management is enabled.
bool isStreamEncrypted () const
 Checks whether stream encryption (TLS) is currently active.
StanzaChannelgetStanzaChannel () const
void setCertificateTrustChecker (CertificateTrustChecker *)
 Sets the certificate trust checker.

Public Attributes

boost::signal< void(const
boost::optional< ClientError > &)> 
onDisconnected
 Emitted when the client was disconnected from the network.
boost::signal< void()> onConnected
 Emitted when the client is connected and authenticated, and stanzas can be sent.
boost::signal< void(const
SafeByteArray &)> 
onDataRead
 Emitted when the client receives data.
boost::signal< void(const
SafeByteArray &)> 
onDataWritten
 Emitted when the client sends data.
boost::signal< void(boost::shared_ptr
< Message >)> 
onMessageReceived
 Emitted when a message is received.
boost::signal< void(boost::shared_ptr
< Presence >) > 
onPresenceReceived
 Emitted when a presence stanza is received.
boost::signal< void(boost::shared_ptr
< Stanza >)> 
onStanzaAcked
 Emitted when the server acknowledges receipt of a stanza (if acknowledgements are available).

Protected Member Functions

boost::shared_ptr< ClientSession > getSession () const
NetworkFactories * getNetworkFactories () const
virtual void handleConnected ()
 Called before onConnected signal is emmitted.

Detailed Description

The central class for communicating with an XMPP server.

This class is responsible for setting up the connection with the XMPP server, authenticating, and initializing the session.

This class can be used directly in your application, although the Client subclass provides more functionality and interfaces, and is better suited for most needs.

Definition at line 49 of file CoreClient.h.


Constructor & Destructor Documentation

Swift::CoreClient::CoreClient ( const JID jid,
const SafeByteArray &  password,
NetworkFactories *  networkFactories 
)

Constructs a client for the given JID with the given password.

The given eventLoop will be used to post events to.

Swift::CoreClient::~CoreClient (  ) 

Member Function Documentation

void Swift::CoreClient::connect ( const ClientOptions &  = ClientOptions()  ) 

Connects the client to the server.

After the connection is established, the client will set initialize the stream and authenticate.

void Swift::CoreClient::disconnect (  ) 

Disconnects the client from the server.

IQRouter* Swift::CoreClient::getIQRouter (  )  const [inline]

Returns the IQ router for this client.

Definition at line 96 of file CoreClient.h.

const JID& Swift::CoreClient::getJID (  )  const

Returns the JID of the client.

After the session was initialized, this returns the bound JID.

NetworkFactories* Swift::CoreClient::getNetworkFactories (  )  const [inline, protected]

Definition at line 200 of file CoreClient.h.

boost::shared_ptr<ClientSession> Swift::CoreClient::getSession (  )  const [inline, protected]

Definition at line 196 of file CoreClient.h.

StanzaChannel* Swift::CoreClient::getStanzaChannel (  )  const
bool Swift::CoreClient::getStreamManagementEnabled (  )  const

Checks whether stream management is enabled.

If stream management is enabled, onStanzaAcked will be emitted when a stanza is received by the server.

See also:
onStanzaAcked
virtual void Swift::CoreClient::handleConnected (  )  [inline, protected, virtual]

Called before onConnected signal is emmitted.

Reimplemented in Swift::Client.

Definition at line 207 of file CoreClient.h.

bool Swift::CoreClient::isActive (  )  const

Checks whether the client is active.

A client is active when it is connected or connecting to the server.

bool Swift::CoreClient::isAvailable (  )  const

Checks whether the client is connected to the server, and stanzas can be sent.

bool Swift::CoreClient::isStreamEncrypted (  )  const

Checks whether stream encryption (TLS) is currently active.

void Swift::CoreClient::sendData ( const std::string &  data  ) 

Sends raw, unchecked data.

void Swift::CoreClient::sendMessage ( boost::shared_ptr< Message  ) 

Sends a message.

void Swift::CoreClient::sendPresence ( boost::shared_ptr< Presence  ) 

Sends a presence stanza.

void Swift::CoreClient::setCertificate ( CertificateWithKey::ref  certificate  ) 

Set a client certificate to use for strong authentication with the server.

Ensure that it is of the correct type for the TLS engine in use. This means, largely, PKCS12Certificate for OpenSSL and CAPICertificate for CAPI.

void Swift::CoreClient::setCertificateTrustChecker ( CertificateTrustChecker  ) 

Sets the certificate trust checker.

This checker will be called when the server sends a TLS certificate that does not validate. If the trust checker says the certificate is trusted, then connecting will proceed; if not, the connection will end with an error.


Member Data Documentation

boost::signal<void ()> Swift::CoreClient::onConnected

Emitted when the client is connected and authenticated, and stanzas can be sent.

Definition at line 159 of file CoreClient.h.

boost::signal<void (const SafeByteArray&)> Swift::CoreClient::onDataRead

Emitted when the client receives data.

This signal is emitted before the XML data is parsed, so this data is unformatted.

Definition at line 167 of file CoreClient.h.

boost::signal<void (const SafeByteArray&)> Swift::CoreClient::onDataWritten

Emitted when the client sends data.

This signal is emitted after the XML was serialized, and is unformatted.

Definition at line 175 of file CoreClient.h.

boost::signal<void (const boost::optional<ClientError>&)> Swift::CoreClient::onDisconnected

Emitted when the client was disconnected from the network.

If the connection was due to a non-recoverable error, the type of error will be passed as a parameter.

Definition at line 153 of file CoreClient.h.

boost::signal<void (boost::shared_ptr<Message>)> Swift::CoreClient::onMessageReceived

Emitted when a message is received.

Definition at line 180 of file CoreClient.h.

boost::signal<void (boost::shared_ptr<Presence>) > Swift::CoreClient::onPresenceReceived

Emitted when a presence stanza is received.

Definition at line 185 of file CoreClient.h.

boost::signal<void (boost::shared_ptr<Stanza>)> Swift::CoreClient::onStanzaAcked

Emitted when the server acknowledges receipt of a stanza (if acknowledgements are available).

See also:
getStreamManagementEnabled()

Definition at line 193 of file CoreClient.h.