#include <AsyncAcceptor.h>
typedef void(* AsyncAcceptor::AcceptCallback)(tcp::socket &&newSocket, uint32 threadIndex) |
AsyncAcceptor::AsyncAcceptor |
( |
boost::asio::io_service & |
ioService, |
|
|
std::string const & |
bindIp, |
|
|
uint16 |
port |
|
) |
| |
|
inline |
34 _acceptor(ioService, tcp::endpoint(boost::asio::ip::address::from_string(bindIp), port)),
std::function< std::pair< tcp::socket *, uint32 >)> _socketFactory
Definition: AsyncAcceptor.h:86
tcp::socket _socket
Definition: AsyncAcceptor.h:84
tcp::acceptor _acceptor
Definition: AsyncAcceptor.h:83
std::pair< tcp::socket *, uint32 > DefeaultSocketFactory()
Definition: AsyncAcceptor.h:81
std::atomic< bool > _closed
Definition: AsyncAcceptor.h:85
template<class T >
void AsyncAcceptor::AsyncAccept |
( |
| ) |
|
99 std::make_shared<T>(std::move(this->
_socket))->Start();
101 catch (boost::system::system_error
const& err)
103 TC_LOG_INFO(
"network",
"Failed to retrieve client's remote address %s", err.what());
109 this->AsyncAccept<T>();
tcp::socket _socket
Definition: AsyncAcceptor.h:84
tcp::acceptor _acceptor
Definition: AsyncAcceptor.h:83
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
std::atomic< bool > _closed
Definition: AsyncAcceptor.h:85
template<AcceptCallback acceptCallback>
void AsyncAcceptor::AsyncAcceptWithCallback |
( |
| ) |
|
|
inline |
48 _acceptor.async_accept(*socket, [
this, socket, threadIndex](boost::system::error_code error)
54 socket->non_blocking(
true);
56 acceptCallback(std::move(*socket), threadIndex);
58 catch (boost::system::system_error
const& err)
60 TC_LOG_INFO(
"network",
"Failed to initialize client's socket %s", err.what());
65 this->AsyncAcceptWithCallback<acceptCallback>();
std::function< std::pair< tcp::socket *, uint32 >)> _socketFactory
Definition: AsyncAcceptor.h:86
tcp::acceptor _acceptor
Definition: AsyncAcceptor.h:83
uint32_t uint32
Definition: Define.h:150
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
std::atomic< bool > _closed
Definition: AsyncAcceptor.h:85
void AsyncAcceptor::Close |
( |
| ) |
|
|
inline |
74 boost::system::error_code err;
tcp::acceptor _acceptor
Definition: AsyncAcceptor.h:83
std::atomic< bool > _closed
Definition: AsyncAcceptor.h:85
std::pair<tcp::socket*, uint32> AsyncAcceptor::DefeaultSocketFactory |
( |
| ) |
|
|
inlineprivate |
81 {
return std::make_pair(&
_socket, 0); }
tcp::socket _socket
Definition: AsyncAcceptor.h:84
void AsyncAcceptor::SetSocketFactory |
( |
std::function< std::pair< tcp::socket *, uint32 >()> |
func | ) |
|
|
inline |
std::function< std::pair< tcp::socket *, uint32 >)> _socketFactory
Definition: AsyncAcceptor.h:86
tcp::acceptor AsyncAcceptor::_acceptor |
|
private |
std::atomic<bool> AsyncAcceptor::_closed |
|
private |
tcp::socket AsyncAcceptor::_socket |
|
private |
std::function<std::pair<tcp::socket*, uint32>)> AsyncAcceptor::_socketFactory |
|
private |
The documentation for this class was generated from the following file: