Remove opcode from read, async_read (API Change):

fix #446

* Read signatures no longer include `opcode`

* stream::got_binary and stream::got_text inform the caller if
  the current incoming message is binary or text.

Actions Required:

* Remove the `opcode` reference parameter from calls to synchronous
  and asynchronous read functions, replace the logic with calls to
  stream::got_binary and stream::got_text instead.
This commit is contained in:
Vinnie Falco
2017-06-08 19:55:42 -07:00
parent 3d6574da81
commit 620ce08d6a
13 changed files with 142 additions and 145 deletions

View File

@@ -151,10 +151,9 @@ boost::asio::ip::tcp::socket sock{ios};
stream<boost::asio::ip::tcp::socket> ws{ios};
//[ws_snippet_15
multi_buffer buffer;
opcode op;
ws.read(op, buffer);
ws.read(buffer);
ws.binary(op == opcode::binary);
ws.text(ws.got_text());
ws.write(buffer.data());
buffer.consume(buffer.size());
//]
@@ -210,9 +209,8 @@ boost::asio::ip::tcp::socket sock{ios};
//]
//[ws_snippet_20
opcode op;
multi_buffer buffer;
ws.async_read(op, buffer,
ws.async_read(buffer,
[](error_code ec)
{
// Do something with the buffer
@@ -226,8 +224,7 @@ boost::asio::ip::tcp::socket sock{ios};
void echo(stream<boost::asio::ip::tcp::socket>& ws,
multi_buffer& buffer, boost::asio::yield_context yield)
{
opcode op;
ws.async_read(op, buffer, yield);
ws.async_read(buffer, yield);
std::future<void> fut =
ws.async_write(buffer.data(), boost::asio::use_future);
}