Examples use bind_front_handler

This commit is contained in:
Vinnie Falco
2019-02-14 16:20:27 -08:00
parent 92add2afa6
commit 18447553ca
26 changed files with 248 additions and 397 deletions

View File

@@ -70,11 +70,9 @@ public:
resolver_.async_resolve(
host,
port,
std::bind(
beast::bind_front_handler(
&session::on_resolve,
shared_from_this(),
std::placeholders::_1,
std::placeholders::_2));
shared_from_this()));
}
void
@@ -92,24 +90,22 @@ public:
beast::async_connect(
beast::get_lowest_layer(ws_),
results,
std::bind(
beast::bind_front_handler(
&session::on_connect,
shared_from_this(),
std::placeholders::_1));
shared_from_this()));
}
void
on_connect(beast::error_code ec)
on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type)
{
if(ec)
return fail(ec, "connect");
// Perform the websocket handshake
ws_.async_handshake(host_, "/",
std::bind(
beast::bind_front_handler(
&session::on_handshake,
shared_from_this(),
std::placeholders::_1));
shared_from_this()));
}
void
@@ -121,11 +117,9 @@ public:
// Send the message
ws_.async_write(
net::buffer(text_),
std::bind(
beast::bind_front_handler(
&session::on_write,
shared_from_this(),
std::placeholders::_1,
std::placeholders::_2));
shared_from_this()));
}
void
@@ -141,11 +135,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
@@ -160,10 +152,9 @@ public:
// Close the WebSocket connection
ws_.async_close(websocket::close_code::normal,
std::bind(
beast::bind_front_handler(
&session::on_close,
shared_from_this(),
std::placeholders::_1));
shared_from_this()));
}
void