forked from boostorg/beast
Boost prep
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#include "../common/root_certificates.hpp"
|
||||
|
||||
#include <beast/core.hpp>
|
||||
#include <beast/websocket.hpp>
|
||||
#include <beast/websocket/ssl.hpp>
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include <boost/beast/websocket/ssl.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/ssl.hpp>
|
||||
#include <cstdlib>
|
||||
@@ -18,13 +20,13 @@
|
||||
|
||||
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
||||
namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
|
||||
namespace websocket = beast::websocket; // from <beast/websocket.hpp>
|
||||
namespace websocket = boost::beast::websocket; // from <boost/beast/websocket.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
// A helper for reporting errors
|
||||
auto const fail =
|
||||
[](std::string what, beast::error_code ec)
|
||||
[](std::string what, boost::beast::error_code ec)
|
||||
{
|
||||
std::cerr << what << ": " << ec.message() << std::endl;
|
||||
std::cerr.flush();
|
||||
@@ -81,7 +83,7 @@ int main()
|
||||
return fail("write", ec);
|
||||
|
||||
// This buffer will hold the incoming message
|
||||
beast::multi_buffer b;
|
||||
boost::beast::multi_buffer b;
|
||||
|
||||
// Read the message into our buffer
|
||||
ws.read(b, ec);
|
||||
@@ -94,13 +96,13 @@ int main()
|
||||
return fail("close", ec);
|
||||
|
||||
// The buffers() function helps print a ConstBufferSequence
|
||||
std::cout << beast::buffers(b.data()) << std::endl;
|
||||
std::cout << boost::beast::buffers(b.data()) << std::endl;
|
||||
|
||||
// WebSocket says that to close a connection you have
|
||||
// to keep reading messages until you receive a close frame.
|
||||
// Beast delivers the close frame as an error from read.
|
||||
//
|
||||
beast::drain_buffer drain; // Throws everything away efficiently
|
||||
boost::beast::drain_buffer drain; // Throws everything away efficiently
|
||||
for(;;)
|
||||
{
|
||||
// Keep reading messages...
|
||||
|
||||
Reference in New Issue
Block a user