boost::asio is used for NPL jabber client's tcp connections.
More...
#include <NPL_TCPConnection.h>
|
| CNPLTCPConnection (boost::asio::io_service &io_service, const LogSink &logInstance, const std::string &server, int port=-1) |
| Constructs a new ConnectionTCPBase object. More...
|
|
| CNPLTCPConnection (boost::asio::io_service &io_service, ConnectionDataHandler *cdh, const LogSink &logInstance, const std::string &server, int port=-1) |
| Constructs a new ConnectionTCPBase object. More...
|
|
virtual | ~CNPLTCPConnection () |
| Virtual destructor.
|
|
virtual bool | send (const std::string &data) |
|
virtual ConnectionError | receive () |
|
virtual void | disconnect () |
|
virtual void | cleanup () |
|
virtual void | getStatistics (long int &totalIn, long int &totalOut) |
|
virtual ConnectionError | recv (int timeout=-1) |
|
virtual ConnectionError | connect () |
|
virtual ConnectionBase * | newInstance () const |
|
void | NotifyDisconnect (ConnectionError error) |
| this function can be called from the io thread to notify disconnection in the main thread. More...
|
|
bool | HasNotification () |
| whether we have notification messages to send. More...
|
|
int | HandleNotification () |
| handle all notifications. More...
|
|
void | Reset (const std::string &server, int port) |
| reset this tcp connection such as changing server and port. More...
|
|
|
void | handle_resolve (const boost::system::error_code &err, tcp::resolver::iterator endpoint_iterator) |
|
void | handle_connect (const boost::system::error_code &error, tcp::resolver::iterator endpoint_iterator) |
|
void | handle_read (const boost::system::error_code &error, std::size_t bytes_transferred) |
|
void | handle_write (const boost::system::error_code &error) |
|
void | handle_disconnect () |
|
CNPLTCPConnection & | operator= (const CNPLTCPConnection &) |
|
void | init (const std::string &server, int port) |
|
boost::asio is used for NPL jabber client's tcp connections.
all NPL_TCPConnection (s) share a single dispatcher io service(one background thread) for DNS resolve, socket connections, and all send and receive message dispatching f.
- when the send message queue is full, new messages will be silently dropped.
- when the receive queue is full, socket connection will be closed.
§ CNPLTCPConnection() [1/2]
CNPLTCPConnection::CNPLTCPConnection |
( |
boost::asio::io_service & |
io_service, |
|
|
const LogSink & |
logInstance, |
|
|
const std::string & |
server, |
|
|
int |
port = -1 |
|
) |
| |
Constructs a new ConnectionTCPBase object.
- Parameters
-
logInstance | The log target. Obtain it from ClientBase::logInstance(). |
server | A server to connect to. |
port | The port to connect to. The default of -1 means that XMPP SRV records will be used to find out about the actual host:port. |
- 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 ConnectionHTTPProxy.
§ CNPLTCPConnection() [2/2]
CNPLTCPConnection::CNPLTCPConnection |
( |
boost::asio::io_service & |
io_service, |
|
|
ConnectionDataHandler * |
cdh, |
|
|
const LogSink & |
logInstance, |
|
|
const std::string & |
server, |
|
|
int |
port = -1 |
|
) |
| |
Constructs a new ConnectionTCPBase object.
- Parameters
-
cdh | An ConnectionDataHandler-derived object that will handle incoming data. |
logInstance | The log target. Obtain it from ClientBase::logInstance(). |
server | A server to connect to. |
port | The port to connect to. The default of -1 means that SRV records will be used to find out about the actual host:port. |
§ HandleNotification()
int CNPLTCPConnection::HandleNotification |
( |
| ) |
|
handle all notifications.
- Returns
- : the number of notifications returned.
§ HasNotification()
bool CNPLTCPConnection::HasNotification |
( |
| ) |
|
whether we have notification messages to send.
§ NotifyDisconnect()
void CNPLTCPConnection::NotifyDisconnect |
( |
ConnectionError |
error | ) |
|
this function can be called from the io thread to notify disconnection in the main thread.
§ Reset()
void ParaEngine::CNPLTCPConnection::Reset |
( |
const std::string & |
server, |
|
|
int |
port |
|
) |
| |
reset this tcp connection such as changing server and port.
§ m_nDisconnectError
ConnectionError ParaEngine::CNPLTCPConnection::m_nDisconnectError |
|
protected |
disconnection error message.
§ m_pIOService
boost::asio::io_service* ParaEngine::CNPLTCPConnection::m_pIOService |
|
protected |
dispatcher IO service object for the connection socket.
§ m_queueInput
the input message queue.
a queue that is filled by incoming messages (the receiving thread) and processed by main thread at regular interval.
§ m_queueOutput
the output message queue.
a queue that is filled by the main thread and send out by a worker thread.
The documentation for this class was generated from the following files:
- Client/trunk/ParaEngineClient/jabber/NPL_TCPConnection.h
- Client/trunk/ParaEngineClient/jabber/NPL_TCPConnection.cpp