ConnectionListener Class Referenceabstract

`#include <connectionlistener.h>`

## Public Member Functions

virtual | ~ConnectionListener ()
virtual void | onConnect ()=0
virtual void | onDisconnect (ConnectionError e)=0
virtual void | onResourceBind (const std::string &resource)
virtual void | onResourceBindError (const Error *error)
virtual void | onSessionCreateError (const Error *error)
virtual bool | onTLSConnect (const CertInfo &info)=0
virtual void | onStreamEvent (StreamEvent event)

## Detailed Description

Derived classes can be registered as ConnectionListeners with the Client.

This interface is mandatory to implement if a connection is to be made TLS-encrypted. In onTLSConnect(), the server's certificate information needs to be checked, and true returned if the certificate is to be accepted.

Author
  Jakob Schröter js@ca.nosp@m.maya.nosp@m..net

Definition at line 33 of file connectionlistener.h.

## Constructor & Destructor Documentation

## ~ConnectionListener()

virtual ~ConnectionListener | ( |  | ) |

inline virtual

Virtual Destructor.

Definition at line 39 of file connectionlistener.h.

## Member Function Documentation

## onConnect()

virtual void onConnect | ( |  | ) |

pure virtual

This function notifies about successful connections. It will be called either after all authentication is finished if username/password were supplied, or after a connection has been established if no credentials were supplied. Depending on the setting of AutoPresence, a presence stanza is sent or not.

## onDisconnect()

virtual void onDisconnect | ( | ConnectionError | e | ) |

pure virtual

This function notifies about disconnection and its reason. If e indicates a stream error, you can use streamError() to find out what exactly went wrong, and streamErrorText() to retrieve any explaining text sent along with the error. If e indicates an authentication error, you can use authError() to get a finer grained reason.

Parameters

  e | The reason for the disconnection.

## onResourceBind()

virtual void onResourceBind | ( | const std::string & | resource | ) |

inline virtual

This function will be called when a resource has been bound to the stream. It will be called for any bound resource, including the main one.

Note
  The bound resource may be different from the one requested. The server has the authority to change/overwrite the requested resource.

Parameters

  resource | The resource string.

Since
  1.0

Definition at line 68 of file connectionlistener.h.

## onResourceBindError()

virtual void onResourceBindError | ( | const Error * | error | ) |

inline virtual

This function is called (by a Client object) if an error occurs while trying to bind a resource.

Parameters

  error | A pointer to an Error object that contains more information. May be 0.

Definition at line 75 of file connectionlistener.h.

## onSessionCreateError()

virtual void onSessionCreateError | ( | const Error * | error | ) |

inline virtual

This function is called (by a Client object) if an error occurs while trying to establish a session.

Parameters

  error | A pointer to an Error object that contains more information. May be 0.

Definition at line 83 of file connectionlistener.h.

## onStreamEvent()

virtual void onStreamEvent | ( | StreamEvent | event | ) |

inline virtual

This function is called for certain stream events. Notifications are purely informational and implementation is optional. Not all StreamEvents will necessarily be emitted for a given connection.

Parameters

  event | A stream event.

Since
  0.9

Definition at line 100 of file connectionlistener.h.

## onTLSConnect()

virtual bool onTLSConnect | ( | const CertInfo & | info | ) |

pure virtual

This function is called when the connection was TLS/SSL secured.

Parameters

  info | Comprehensive info on the certificate.

Returns
  True if cert credentials are accepted, false otherwise. If false is returned the connection is terminated.

The documentation for this class was generated from the following file:

- connectionlistener.h