31 FETPAPI_DLL_IMPORT_OR_EXPORT PlainClientSession(
32 InitializationParameters const* initializationParams,
const std::string & target,
const std::string & authorization,
const std::string& proxyAuthorization =
"",
33 const std::map<std::string, std::string>& additionalHandshakeHeaderFields = {}, std::size_t frameSize = 4096);
35 virtual ~PlainClientSession() =
default;
38#if BOOST_VERSION < 107000
39 FETPAPI_DLL_IMPORT_OR_EXPORT std::unique_ptr<websocket::stream<tcp::socket>>& ws() {
return ws_; }
41 FETPAPI_DLL_IMPORT_OR_EXPORT std::unique_ptr<websocket::stream<boost::beast::tcp_stream>>& ws() {
return ws_; }
44 bool isTls()
const final{
return false; }
46 void asyncConnect(
const tcp::resolver::results_type& results)
49 std::vector<tcp::endpoint> endpoints = std::vector<tcp::endpoint>(results.begin(), results.end());
50 std::stable_partition(endpoints.begin(), endpoints.end(), [](
auto entry) {return entry.protocol() == tcp::v4(); });
52#if BOOST_VERSION < 107000
53 ws_.reset(
new websocket::stream<tcp::socket>(ioc));
54 ws_->write_buffer_size(frameSize_);
58 boost::asio::async_connect(
63 &AbstractClientSessionCRTP::on_ssl_handshake,
64 std::static_pointer_cast<AbstractClientSessionCRTP>(shared_from_this()),
65 std::placeholders::_1));
67 ws_.reset(
new websocket::stream<boost::beast::tcp_stream>(ioc));
68 ws_->write_buffer_bytes(frameSize_);
72 boost::beast::get_lowest_layer(*ws_).async_connect(
74 boost::beast::bind_front_handler(
75 &PlainClientSession::on_connect,
76 std::static_pointer_cast<PlainClientSession>(shared_from_this())));
80#if BOOST_VERSION > 106900
81 void on_connect(boost::beast::error_code ec, tcp::resolver::results_type::endpoint_type)
88#if BOOST_VERSION < 107000
89 std::unique_ptr<websocket::stream<tcp::socket>> ws_;
91 std::unique_ptr<websocket::stream<boost::beast::tcp_stream>> ws_;
93 std::size_t frameSize_;