forked from boostorg/beast
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user