WebSocket writes return the bytes transferred (API Change):

* Stream write operations now return the number of bytes
transferred from the caller's input buffers.

Actions Required:

* Modify websocket write completion handlers to receive
  the extra std::size_t bytes_transferred parameter.
This commit is contained in:
Vinnie Falco
2017-09-03 06:18:07 -07:00
parent 942bca0cc3
commit c0e5f14702
19 changed files with 287 additions and 129 deletions

View File

@@ -61,13 +61,16 @@ public:
void
run()
{
loop();
loop({}, 0);
}
#include <boost/asio/yield.hpp>
void
loop(boost::system::error_code ec = {})
loop(
boost::system::error_code ec,
std::size_t bytes_transferred)
{
boost::ignore_unused(bytes_transferred);
reenter(*this)
{
// Accept the websocket handshake
@@ -75,7 +78,8 @@ public:
strand_.wrap(std::bind(
&session::loop,
shared_from_this(),
std::placeholders::_1)));
std::placeholders::_1,
0)));
if(ec)
return fail(ec, "accept");
@@ -87,7 +91,8 @@ public:
strand_.wrap(std::bind(
&session::loop,
shared_from_this(),
std::placeholders::_1)));
std::placeholders::_1,
std::placeholders::_2)));
if(ec == websocket::error::closed)
{
// This indicates that the session was closed
@@ -103,7 +108,8 @@ public:
strand_.wrap(std::bind(
&session::loop,
shared_from_this(),
std::placeholders::_1)));
std::placeholders::_1,
std::placeholders::_2)));
if(ec)
return fail(ec, "write");