gloox  1.0
Public Types | Public Member Functions | List of all members
ConnectionBOSH Class Reference

#include <connectionbosh.h>

Inheritance diagram for ConnectionBOSH:
Inheritance graph
[legend]

Public Types

enum  ConnMode { ModeLegacyHTTP, ModePersistentHTTP, ModePipelining }

Public Member Functions

 ConnectionBOSH (ConnectionBase *connection, const LogSink &logInstance, const std::string &boshHost, const std::string &xmppServer, int xmppPort=5222)
 ConnectionBOSH (ConnectionDataHandler *cdh, ConnectionBase *connection, const LogSink &logInstance, const std::string &boshHost, const std::string &xmppServer, int xmppPort=5222)
virtual ~ConnectionBOSH ()
void setServer (const std::string &xmppHost, unsigned short xmppPort=5222)
void setPath (const std::string &path)
void setMode (ConnMode mode)
- Public Member Functions inherited from ConnectionBase
 ConnectionBase (ConnectionDataHandler *cdh)
virtual ~ConnectionBase ()
virtual ConnectionError connect ()=0
virtual ConnectionError recv (int timeout=-1)=0
virtual bool send (const std::string &data)=0
virtual ConnectionError receive ()=0
virtual void disconnect ()=0
virtual void cleanup ()
ConnectionState state () const
void registerConnectionDataHandler (ConnectionDataHandler *cdh)
void setServer (const std::string &server, int port=-1)
const std::string & server () const
int port () const
virtual int localPort () const
virtual const std::string localInterface () const
virtual void getStatistics (long int &totalIn, long int &totalOut)=0
virtual ConnectionBasenewInstance () const =0

Additional Inherited Members

- Protected Attributes inherited from ConnectionBase
ConnectionDataHandlerm_handler
ConnectionState m_state
std::string m_server
int m_port
- Private Member Functions inherited from ConnectionDataHandler
virtual ~ConnectionDataHandler ()
virtual void handleReceivedData (const ConnectionBase *connection, const std::string &data)=0
virtual void handleConnect (const ConnectionBase *connection)=0
virtual void handleDisconnect (const ConnectionBase *connection, ConnectionError reason)=0
- Private Member Functions inherited from TagHandler
virtual ~TagHandler ()
virtual void handleTag (Tag *tag)=0

Detailed Description

This is an implementation of a BOSH (HTTP binding) connection.

Usage:

Client *c = new Client( ... );
c->setConnectionImpl( new ConnectionBOSH( c,
new ConnectionTCPClient( c->logInstance(), httpServer, httpPort ),
c->logInstance(), boshHost, xmpphost, xmppPort ) );

Make sure to pass the BOSH connection manager's host/port to the transport connection (ConnectionTCPClient in this case), and the XMPP server's host and port to the BOSH connection. You must also pass to BOSH the address of the BOSH server you are dealing with, this is used in the HTTP Host header.

In the case of using ConnectionBOSH through a HTTP proxy, supply httpServer and httpPort as those of the proxy. In all cases, boshHost should be set to the hostname (not IP address) of the server running the BOSH connection manager.

The reason why ConnectionBOSH doesn't manage its own ConnectionTCPClient is that it allows it to be used with other transports (like chained SOCKS5/HTTP proxies, or ConnectionTLS for HTTPS).

Note
To avoid problems, you should disable TLS in gloox by calling ClientBase::setTls( TLSDisabled ).

Sample configurations for different servers can be found in the bosh_example.cpp file included with gloox in the src/examples/ directory.

Author
Matthew Wild mwild.nosp@m.1@gm.nosp@m.ail.c.nosp@m.om
Jakob Schroeter js@ca.nosp@m.maya.nosp@m..net
Since
1.0

Definition at line 64 of file connectionbosh.h.

Member Enumeration Documentation

enum ConnMode

The supported connection modes. Usually auto-detected.

Enumerator:
ModeLegacyHTTP 

HTTP 1.0 connections, closed after receiving a response

ModePersistentHTTP 

HTTP 1.1 connections, re-used after receiving a response

ModePipelining 

HTTP Pipelining (implies HTTP 1.1) a single connection is used

Definition at line 110 of file connectionbosh.h.

Constructor & Destructor Documentation

ConnectionBOSH ( ConnectionBase connection,
const LogSink logInstance,
const std::string &  boshHost,
const std::string &  xmppServer,
int  xmppPort = 5222 
)

Constructs a new ConnectionBOSH object.

Parameters
connectionA transport connection. It should be configured to connect to the BOSH connection manager's (or a HTTP proxy's) host and port, not to the XMPP host. ConnectionBOSH will own the transport connection and delete it in its destructor.
logInstanceThe log target. Obtain it from ClientBase::logInstance().
boshHostThe hostname of the BOSH connection manager
xmppServerA server to connect to. This is the XMPP server's address, not the connection manager's.
xmppPortThe port to connect to. This is the XMPP server's port, not the connection manager's.
Note
To properly use this object, you have to set a ConnectionDataHandler using registerConnectionDataHandler(). This is not necessary if this object is part of a 'connection chain', e.g. with ConnectionSOCKS5Proxy.

Definition at line 31 of file connectionbosh.cpp.

ConnectionBOSH ( ConnectionDataHandler cdh,
ConnectionBase connection,
const LogSink logInstance,
const std::string &  boshHost,
const std::string &  xmppServer,
int  xmppPort = 5222 
)

Constructs a new ConnectionBOSH object.

Parameters
cdhAn ConnectionDataHandler-derived object that will handle incoming data.
connectionA transport connection. It should be configured to connect to the connection manager's (or proxy's) host and port, not to the XMPP host. ConnectionBOSH will own the transport connection and delete it in its destructor.
logInstanceThe log target. Obtain it from ClientBase::logInstance().
boshHostThe hostname of the BOSH connection manager (not any intermediate proxy)
xmppServerA server to connect to. This is the XMPP server's address, not the connection manager's.
xmppPortThe port to connect to. This is the XMPP server's port, not the connection manager's.

Definition at line 44 of file connectionbosh.cpp.

~ConnectionBOSH ( )
virtual

Virtual destructor

Definition at line 76 of file connectionbosh.cpp.

Member Function Documentation

void setMode ( ConnMode  mode)
inline

Sets the connection mode

Parameters
modeThe connection mode,
See Also
ConnMode
Note
In the case that a mode is selected that the connection manager or proxy does not support, gloox will fall back to using HTTP/1.0 connections, which should work with any server.

Definition at line 139 of file connectionbosh.h.

void setPath ( const std::string &  path)
inline

Sets the path on the connection manager to request

Parameters
pathThe path, the default is "/http-bind/", which is the default for many connection managers.

Definition at line 130 of file connectionbosh.h.

void setServer ( const std::string &  xmppHost,
unsigned short  xmppPort = 5222 
)
inline

Sets the XMPP server to proxy to.

Parameters
xmppHostThe XMPP server hostname (IP address).
xmppPortThe XMPP server port.

Definition at line 122 of file connectionbosh.h.


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