4#include <boost/asio.hpp>
5#include <boost/asio/ssl.hpp>
6#include <boost/beast/core.hpp>
7#include <boost/beast/ssl.hpp>
8#include <boost/beast/websocket.hpp>
9#include <boost/beast/websocket/ssl.hpp>
35 static constexpr int connection_timeout_seconds = 30;
37 boost::asio::ssl::context ssl_context_;
38 boost::asio::ip::tcp::resolver resolver_;
39 boost::beast::websocket::stream<boost::beast::ssl_stream<boost::beast::tcp_stream>> ws_;
40 boost::beast::flat_buffer read_buffer_;
57 std::function<
void(
const boost::system::error_code &, std::size_t)> handler) -> void;
66 std::function<
void(
const boost::system::error_code &, std::size_t)> handler) -> void;
74 auto async_read(
const boost::asio::mutable_buffer &buffer,
75 std::function<
void(
const boost::system::error_code &, std::size_t)> handler) -> void;
82 auto async_close(std::function<
void(
const boost::system::error_code &, std::size_t)> handler) -> void;
WebSocket stream with TLS support.
auto async_close(std::function< void(const boost::system::error_code &, std::size_t)> handler) -> void
Asynchronously closes the WebSocket connection.
auto async_read(const boost::asio::mutable_buffer &buffer, std::function< void(const boost::system::error_code &, std::size_t)> handler) -> void
Asynchronously reads data from the WebSocket.
auto async_write(std::span< const std::byte > data, std::function< void(const boost::system::error_code &, std::size_t)> handler) -> void
Asynchronously writes data to the WebSocket.
websocket_stream(const std::shared_ptr< boost::asio::io_context > &io_context)
Constructs a WebSocket stream.
auto async_connect(websocket_connection_params params, std::function< void(const boost::system::error_code &, std::size_t)> handler) -> void
Asynchronously connects to a WebSocket endpoint.
Parameters for establishing a WebSocket connection.
std::string_view port
Port number (typically "443" for wss://)
std::string_view host
Hostname or IP address.
std::string_view path
WebSocket path (e.g., "/" or "/api/v1")