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 20:05:19 -07:00
parent 942bca0cc3
commit c0e5f14702
19 changed files with 287 additions and 129 deletions
+4 -2
View File
@@ -104,12 +104,13 @@ public:
ws.handshake("localhost", "/");
std::size_t count = 0;
ws.async_write(sbuf("Hello, world"),
[&](error_code ec)
[&](error_code ec, std::size_t n)
{
++count;
if(ec)
BOOST_THROW_EXCEPTION(
system_error{ec});
BEAST_EXPECT(n == 12);
});
BEAST_EXPECT(ws.wr_block_);
BEAST_EXPECT(count == 0);
@@ -333,12 +334,13 @@ public:
ws.handshake("localhost", "/");
std::size_t count = 0;
ws.async_write(sbuf("*"),
[&](error_code ec)
[&](error_code ec, std::size_t n)
{
++count;
if(ec)
BOOST_THROW_EXCEPTION(
system_error{ec});
BEAST_EXPECT(n == 1);
});
BEAST_EXPECT(ws.wr_block_);
ws.async_ping("",