Fix README websocket example

fix #385
This commit is contained in:
Vinnie Falco
2017-05-24 07:22:56 -07:00
parent 600f6da5a3
commit 00caf76f9e
2 changed files with 5 additions and 4 deletions

View File

@ -6,6 +6,7 @@ Version 44
* Tidy up and make get_lowest_layer public * Tidy up and make get_lowest_layer public
* Use BOOST_STATIC_ASSERT * Use BOOST_STATIC_ASSERT
* Fix async return values in docs * Fix async return values in docs
* Fix README websocket example
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -156,7 +156,7 @@ and run yourself (they are in the `examples` directory).
Example WebSocket program: Example WebSocket program:
```C++ ```C++
#include <beast/core/to_string.hpp> #include <beast/core.hpp>
#include <beast/websocket.hpp> #include <beast/websocket.hpp>
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <iostream> #include <iostream>
@ -178,11 +178,11 @@ int main()
ws.write(boost::asio::buffer(std::string("Hello, world!"))); ws.write(boost::asio::buffer(std::string("Hello, world!")));
// Receive WebSocket message, print and close using beast // Receive WebSocket message, print and close using beast
beast::streambuf sb; beast::multi_buffer b;
beast::websocket::opcode op; beast::websocket::opcode op;
ws.read(op, sb); ws.read(op, b);
ws.close(beast::websocket::close_code::normal); ws.close(beast::websocket::close_code::normal);
std::cout << beast::to_string(sb.data()) << "\n"; std::cout << beast::buffers(b.data()) << "\n";
} }
``` ```