Connection class, responsible of send/receive data from any client or server. Regardless its communication protocol or synchrony.
#include <tcpServer.h>
|
|
void | setDisconnectHandler (std::function< void(pointer)> h) |
| |
| boost::asio::ip::tcp::socket & | socket () |
| | Boost TCP socket. More...
|
| |
| bool | isDisconnected () |
| | returns if it is disconected More...
|
| |
|
void | disconnect () |
| | Disconnect function for TCP socket.
|
| |
| void | write (std::string sendData) |
| | Function responsible of send the data through the socket. More...
|
| |
|
void | receive () |
| | Asynchronous receiving.
|
| |
| void | setWriteStatusHandler (boost::function< void(const boost::system::error_code &error, std::size_t size)> writeStatusHandler) |
| | To set the write handler. More...
|
| |
| void | setReceiveSendHandler (boost::function< void(const boost::system::error_code &error, const char *receiveData, std::string &sendData)> receiveSendHandler) |
| | To set the read handler. More...
|
| |
|
| static pointer | create (BOOST_IO_CONTEXT &io_context) |
| | Static function to create the boost share object of Connection related to an io context. It is one way to hide the Connection class only available for Server class. More...
|
| |
|
|
std::function< void(pointer)> | mOnDisconnect |
| |
| static pointer create |
( |
BOOST_IO_CONTEXT & |
io_context | ) |
|
|
static |
- Parameters
-
| io_context | The service for the connection. |
- Returns
- The share object.
- Returns
- true if it is disconected
| void setReceiveSendHandler |
( |
boost::function< void(const boost::system::error_code &error, const char *receiveData, std::string &sendData)> |
receiveSendHandler | ) |
|
- Parameters
-
| receiveSendHandler | The read handler to send data. |
| void setWriteStatusHandler |
( |
boost::function< void(const boost::system::error_code &error, std::size_t size)> |
writeStatusHandler | ) |
|
- Parameters
-
| writeStatusHandler | The write handler to call when finish. |
| boost::asio::ip::tcp::socket& socket |
( |
| ) |
|
- Returns
- socketBoost TCP socket.
| void write |
( |
std::string |
sendData | ) |
|
- Parameters
-
| sendData | The data to send. |