Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
StreamData.hpp
1#pragma once
2
3#include "util/requests/impl/SslContext.hpp"
4
5#include <boost/asio/associated_executor.hpp>
6#include <boost/asio/spawn.hpp>
7#include <boost/asio/ssl/context.hpp>
8#include <boost/asio/ssl/stream.hpp>
9#include <boost/beast/core/error.hpp>
10#include <boost/beast/core/tcp_stream.hpp>
11#include <boost/beast/ssl/ssl_stream.hpp>
12#include <boost/beast/websocket.hpp>
13#include <boost/beast/websocket/stream.hpp>
14
15namespace util::requests::impl {
16
17template <typename StreamType>
18struct PlainStreamData {
19 static constexpr bool kSslEnabled = false;
20
21 explicit PlainStreamData(boost::asio::yield_context yield)
22 : stream(boost::asio::get_associated_executor(yield))
23 {
24 }
25
26 StreamType stream;
27};
28
31
32template <typename StreamType>
33struct SslStreamData {
34 static constexpr bool kSslEnabled = true;
35 StreamType stream;
36
37 static SslStreamData
38 create(boost::asio::yield_context yield)
39 {
40 return SslStreamData{getClientSslContext(), yield};
41 }
42
43private:
44 SslStreamData(boost::asio::ssl::context& sslContext, boost::asio::yield_context yield)
45 : stream(boost::asio::get_associated_executor(yield), sslContext)
46 {
47 }
48};
49
51using SslWsStreamData = SslStreamData<
52 boost::beast::websocket::stream<boost::asio::ssl::stream<boost::beast::tcp_stream>>>;
53
54} // namespace util::requests::impl
Definition StreamData.hpp:18
Definition StreamData.hpp:33