forked from boostorg/beast
Examples use bind_front_handler
This commit is contained in:
@@ -69,10 +69,9 @@ public:
|
||||
// Perform the SSL handshake
|
||||
ws_.next_layer().async_handshake(
|
||||
ssl::stream_base::server,
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&session::on_handshake,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -83,10 +82,9 @@ public:
|
||||
|
||||
// Accept the websocket handshake
|
||||
ws_.async_accept(
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&session::on_accept,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -105,11 +103,9 @@ public:
|
||||
// Read a message into our buffer
|
||||
ws_.async_read(
|
||||
buffer_,
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&session::on_read,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -130,11 +126,9 @@ public:
|
||||
ws_.text(ws_.got_text());
|
||||
ws_.async_write(
|
||||
buffer_.data(),
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&session::on_write,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -220,11 +214,9 @@ public:
|
||||
do_accept()
|
||||
{
|
||||
acceptor_.async_accept(
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -60,10 +60,9 @@ public:
|
||||
{
|
||||
// Accept the websocket handshake
|
||||
ws_.async_accept(
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&session::on_accept,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -82,11 +81,9 @@ public:
|
||||
// Read a message into our buffer
|
||||
ws_.async_read(
|
||||
buffer_,
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&session::on_read,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -107,11 +104,9 @@ public:
|
||||
ws_.text(ws_.got_text());
|
||||
ws_.async_write(
|
||||
buffer_.data(),
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&session::on_write,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -194,11 +189,9 @@ public:
|
||||
do_accept()
|
||||
{
|
||||
acceptor_.async_accept(
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -206,11 +206,9 @@ run()
|
||||
|
||||
// Read a request
|
||||
http::async_read(stream_, buffer_, req_,
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&http_session::on_read,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
// Report a failure
|
||||
@@ -348,9 +346,7 @@ on_write(beast::error_code ec, std::size_t, bool close)
|
||||
|
||||
// Read another request
|
||||
http::async_read(stream_, buffer_, req_,
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&http_session::on_read,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
@@ -61,11 +61,9 @@ run()
|
||||
{
|
||||
// Start accepting a connection
|
||||
acceptor_.async_accept(
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
// Report a failure
|
||||
@@ -94,9 +92,7 @@ on_accept(beast::error_code ec, tcp::socket socket)
|
||||
|
||||
// Accept another connection
|
||||
acceptor_.async_accept(
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
@@ -52,11 +52,9 @@ on_accept(beast::error_code ec)
|
||||
// Read a message
|
||||
ws_.async_read(
|
||||
buffer_,
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&websocket_session::on_read,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -76,11 +74,9 @@ on_read(beast::error_code ec, std::size_t)
|
||||
// Read another message
|
||||
ws_.async_read(
|
||||
buffer_,
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&websocket_session::on_read,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -93,7 +89,7 @@ send(boost::shared_ptr<std::string const> const& ss)
|
||||
if(! ws_.get_executor().running_in_this_thread())
|
||||
return net::post(
|
||||
ws_.get_executor(),
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&websocket_session::send,
|
||||
shared_from_this(),
|
||||
ss));
|
||||
@@ -108,11 +104,9 @@ send(boost::shared_ptr<std::string const> const& ss)
|
||||
// We are not currently writing, so send this immediately
|
||||
ws_.async_write(
|
||||
net::buffer(*queue_.front()),
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&websocket_session::on_write,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -130,9 +124,7 @@ on_write(beast::error_code ec, std::size_t)
|
||||
if(! queue_.empty())
|
||||
ws_.async_write(
|
||||
net::buffer(*queue_.front()),
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&websocket_session::on_write,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
@@ -60,10 +60,9 @@ run(http::request<Body, http::basic_fields<Allocator>> req)
|
||||
// Accept the websocket handshake
|
||||
ws_.async_accept(
|
||||
req,
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&websocket_session::on_accept,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -131,9 +131,9 @@ do_sync_listen(
|
||||
if(ec)
|
||||
return fail(ec, "accept");
|
||||
|
||||
std::thread{std::bind(
|
||||
std::thread(std::bind(
|
||||
&do_sync_session,
|
||||
ws_type(std::move(socket)))}.detach();
|
||||
ws_type(std::move(socket)))).detach();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,10 +165,9 @@ public:
|
||||
res.set(http::field::server,
|
||||
"Boost.Beast/" + std::to_string(BOOST_BEAST_VERSION) + "-Async");
|
||||
},
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&async_session::on_accept,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -187,11 +186,9 @@ public:
|
||||
// Read a message into our buffer
|
||||
ws_.async_read(
|
||||
buffer_,
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&async_session::on_read,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -212,11 +209,9 @@ public:
|
||||
ws_.text(ws_.got_text());
|
||||
ws_.async_write(
|
||||
buffer_.data(),
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&async_session::on_write,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -297,11 +292,9 @@ public:
|
||||
do_accept()
|
||||
{
|
||||
acceptor_.async_accept(
|
||||
std::bind(
|
||||
beast::bind_front_handler(
|
||||
&async_listener::on_accept,
|
||||
shared_from_this(),
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -428,7 +421,7 @@ int main(int argc, char* argv[])
|
||||
net::io_context ioc{threads};
|
||||
|
||||
// Create sync port
|
||||
std::thread(std::bind(
|
||||
std::thread(beast::bind_front_handler(
|
||||
&do_sync_listen,
|
||||
std::ref(ioc),
|
||||
tcp::endpoint{
|
||||
|
||||
Reference in New Issue
Block a user