9 #include <boost/asio/post.hpp> 21 : _io_context(io_context),
22 _acceptor(_io_context,
std::move(ep)),
24 _synchronous(false) {}
30 using boost::system::error_code;
32 auto session = std::make_shared<ServerSession>(
_io_context, timeout, *
this);
34 auto handle_query = [on_opened, on_closed, session](
const error_code &ec) {
36 session->Open(std::move(on_opened), std::move(on_closed));
38 log_error(
"tcp accept stream error:", ec.message());
42 _acceptor.async_accept(session->_socket, [=](error_code ec) {
44 boost::asio::post(_io_context, [=]() { handle_query(ec); });
boost::asio::io_context & _io_context
boost::asio::ip::tcp::endpoint endpoint
static void log_error(Args &&... args)
This file contains definitions of common data structures used in traffic manager. ...
std::function< void(std::shared_ptr< ServerSession >)> callback_function_type
Positive time duration up to milliseconds resolution.
Server(boost::asio::io_context &io_context, endpoint ep)
void OpenSession(time_duration timeout, ServerSession::callback_function_type on_session_opened, ServerSession::callback_function_type on_session_closed)
boost::asio::ip::tcp::acceptor _acceptor