forked from boostorg/beast
role_type is in boost/beast/core/role.hpp (API Change):
This enumeration is now part of the library core and not specific to websocket.
This commit is contained in:
@@ -62,6 +62,7 @@ add_executable (tests-beast-core
|
||||
ostream.cpp
|
||||
rate_policy.cpp
|
||||
read_size.cpp
|
||||
role.cpp
|
||||
saved_handler.cpp
|
||||
span.cpp
|
||||
static_buffer.cpp
|
||||
|
||||
@@ -50,6 +50,7 @@ local SOURCES =
|
||||
ostream.cpp
|
||||
rate_policy.cpp
|
||||
read_size.cpp
|
||||
role.cpp
|
||||
saved_handler.cpp
|
||||
span.cpp
|
||||
static_buffer.cpp
|
||||
|
||||
@@ -1200,13 +1200,13 @@ public:
|
||||
{
|
||||
error_code ec;
|
||||
stream_type s(ioc);
|
||||
teardown(websocket::role_type::client, s, ec);
|
||||
teardown(role_type::client, s, ec);
|
||||
}
|
||||
|
||||
{
|
||||
error_code ec;
|
||||
stream_type s(ioc);
|
||||
async_teardown(websocket::role_type::server, s,
|
||||
async_teardown(role_type::server, s,
|
||||
[](error_code)
|
||||
{
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||
#include <boost/beast/_experimental/test/stream.hpp>
|
||||
#include <boost/beast/websocket/role.hpp>
|
||||
#include <boost/beast/core/role.hpp>
|
||||
#include <initializer_list>
|
||||
#include <vector>
|
||||
|
||||
@@ -162,14 +162,14 @@ public:
|
||||
flat_stream<test::stream> s(ioc);
|
||||
ts.connect(s.next_layer());
|
||||
error_code ec;
|
||||
teardown(websocket::role_type::client, s, ec);
|
||||
teardown(role_type::client, s, ec);
|
||||
}
|
||||
|
||||
{
|
||||
test::stream ts(ioc);
|
||||
flat_stream<test::stream> s(ioc);
|
||||
ts.connect(s.next_layer());
|
||||
async_teardown(websocket::role_type::client, s,
|
||||
async_teardown(role_type::client, s,
|
||||
[](error_code)
|
||||
{
|
||||
});
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/beast/websocket/role.hpp>
|
||||
#include <boost/beast/core/role.hpp>
|
||||
@@ -32,7 +32,6 @@ add_executable (tests-beast-websocket
|
||||
read2.cpp
|
||||
read3.cpp
|
||||
rfc6455.cpp
|
||||
role.cpp
|
||||
stream.cpp
|
||||
stream_base.cpp
|
||||
stream_explicit.cpp
|
||||
|
||||
@@ -22,7 +22,6 @@ local SOURCES =
|
||||
read2.cpp
|
||||
read3.cpp
|
||||
rfc6455.cpp
|
||||
role.cpp
|
||||
stream.cpp
|
||||
stream_base.cpp
|
||||
stream_explicit.cpp
|
||||
|
||||
@@ -26,6 +26,7 @@ add_executable (tests-doc
|
||||
http_10_custom_parser.cpp
|
||||
http_examples.cpp
|
||||
http_snippets.cpp
|
||||
websocket.cpp
|
||||
websocket_3_handshake.cpp
|
||||
websocket_snippets.cpp
|
||||
exemplars.cpp
|
||||
|
||||
@@ -24,6 +24,7 @@ alias run-tests :
|
||||
[ run core_4_layers.cpp $(TEST_MAIN) ]
|
||||
[ run http_10_custom_parser.cpp $(TEST_MAIN) ]
|
||||
[ run http_examples.cpp $(TEST_MAIN) ]
|
||||
[ run websocket.cpp $(TEST_MAIN) ]
|
||||
[ run websocket_3_handshake.cpp $(TEST_MAIN) ]
|
||||
;
|
||||
|
||||
@@ -34,6 +35,7 @@ exe fat-tests :
|
||||
core_4_layers.cpp
|
||||
http_10_custom_parser.cpp
|
||||
http_examples.cpp
|
||||
websocket.cpp
|
||||
websocket_3_handshake.cpp
|
||||
;
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
//
|
||||
// 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 "snippets.hpp"
|
||||
|
||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4459) // declaration hides global declaration
|
||||
#endif
|
||||
|
||||
//[code_websocket_1a
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/beast/ssl.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
//]
|
||||
|
||||
namespace {
|
||||
|
||||
//[code_websocket_1b
|
||||
namespace net = boost::asio;
|
||||
using namespace boost::beast;
|
||||
using namespace boost::beast::websocket;
|
||||
|
||||
net::io_context ioc;
|
||||
net::ssl::context ctx(net::ssl::context::sslv23);
|
||||
|
||||
//]
|
||||
|
||||
void
|
||||
websocket_snippets()
|
||||
{
|
||||
{
|
||||
//[code_websocket_1f
|
||||
|
||||
// This newly constructed WebSocket stream will use the specified
|
||||
// I/O context and have support for the permessage-deflate extension.
|
||||
|
||||
stream<tcp_stream> ws(ioc);
|
||||
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[code_websocket_2f
|
||||
|
||||
// The `tcp_stream` will be constructed with a new strand which
|
||||
// uses the specified I/O context.
|
||||
|
||||
stream<tcp_stream> ws(make_strand(ioc));
|
||||
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[code_websocket_3f
|
||||
|
||||
// The WebSocket stream will use SSL and a new strand
|
||||
stream<ssl_stream<tcp_stream>> wss(make_strand(ioc), ctx);
|
||||
|
||||
//
|
||||
//]
|
||||
}
|
||||
}
|
||||
|
||||
} // (anon)
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
struct websocket_snippets_test
|
||||
: public beast::unit_test::suite
|
||||
{
|
||||
void
|
||||
run() override
|
||||
{
|
||||
BEAST_EXPECT(&websocket_snippets);
|
||||
pass();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(beast,doc,websocket_snippets);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
@@ -10,18 +10,17 @@
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/spawn.hpp>
|
||||
#include <boost/asio/ssl.hpp>
|
||||
#include <boost/asio/use_future.hpp>
|
||||
#include <algorithm>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
//[ws_snippet_1
|
||||
using namespace boost::beast;
|
||||
|
||||
#include <boost/beast/websocket.hpp>
|
||||
using namespace boost::beast::websocket;
|
||||
//]
|
||||
|
||||
using namespace boost::beast;
|
||||
|
||||
namespace doc_ws_snippets {
|
||||
|
||||
@@ -34,12 +33,6 @@ error_code ec;
|
||||
net::ip::tcp::socket sock{ioc};
|
||||
boost::ignore_unused(ec);
|
||||
|
||||
{
|
||||
//[ws_snippet_2
|
||||
stream<net::ip::tcp::socket> ws{ioc};
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[ws_snippet_3
|
||||
stream<net::ip::tcp::socket> ws{std::move(sock)};
|
||||
@@ -277,25 +270,10 @@ struct custom_wrapper
|
||||
|
||||
//]
|
||||
|
||||
//[ws_snippet_26
|
||||
|
||||
// A WebSocket stream
|
||||
template<
|
||||
class NextLayer,
|
||||
bool deflateSupported = true>
|
||||
class stream;
|
||||
|
||||
//]
|
||||
|
||||
} // doc_ws_snippets
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//[wss_snippet_1
|
||||
#include <boost/beast/websocket/ssl.hpp>
|
||||
#include <boost/asio/ssl.hpp>
|
||||
//]
|
||||
|
||||
namespace doc_wss_snippets {
|
||||
|
||||
void fxx() {
|
||||
@@ -306,13 +284,6 @@ std::thread t{[&](){ ioc.run(); }};
|
||||
error_code ec;
|
||||
net::ip::tcp::socket sock{ioc};
|
||||
|
||||
{
|
||||
//[wss_snippet_2
|
||||
net::ssl::context ctx{net::ssl::context::sslv23};
|
||||
stream<net::ssl::stream<net::ip::tcp::socket>> wss{ioc, ctx};
|
||||
//]
|
||||
}
|
||||
|
||||
{
|
||||
//[wss_snippet_3
|
||||
net::ip::tcp::endpoint ep;
|
||||
|
||||
Reference in New Issue
Block a user