8#include <promise-cpp/promise.hpp>
9#include <boost/beast/ssl/ssl_stream.hpp>
10#include <boost/beast/core/tcp_stream.hpp>
11#include <boost/beast/websocket.hpp>
12#include <boost/beast/websocket/ssl.hpp>
18 class WebsocketBase :
public std::enable_shared_from_this<WebsocketBase>
23 boost::beast::websocket::stream<boost::beast::ssl_stream<Detail::StreamType>>,
24 boost::beast::websocket::stream<Detail::StreamType>>&& ws);
31 template <
typename FunctionT>
34 return std::visit(std::forward<FunctionT>(func),
ws_);
37 template <
typename FunctionT>
40 return std::visit(std::forward<FunctionT>(func),
ws_);
80 send(std::string message);
122 bool close(std::chrono::seconds closeWaitTimeout = std::chrono::seconds{3});
126 boost::beast::websocket::stream<boost::beast::ssl_stream<Detail::StreamType>>,
127 boost::beast::websocket::stream<Detail::StreamType>>
Definition websocket_base.hpp:19
Detail::PromiseTypeBind< Detail::PromiseTypeBindThen< WebsocketReadResult >, Detail::PromiseTypeBindFail< Error const & > > read()
Reads something from the server.
Definition websocket_base.cpp:78
WebsocketBase & operator=(WebsocketBase &&)=delete
auto withStreamDo(FunctionT &&func) const
Definition websocket_base.hpp:38
bool close(std::chrono::seconds closeWaitTimeout=std::chrono::seconds{3})
Closes the websocket connection.
Definition websocket_base.cpp:143
WebsocketBase & operator=(WebsocketBase const &)=delete
std::size_t readMessageMax() const
Returns the maximum incoming message size setting.
Definition websocket_base.cpp:40
WebsocketBase(WebsocketBase &&)=delete
std::variant< boost::beast::websocket::stream< boost::beast::ssl_stream< Detail::StreamType > >, boost::beast::websocket::stream< Detail::StreamType > > ws_
Definition websocket_base.hpp:128
Detail::PromiseTypeBind< Detail::PromiseTypeBindThen< WebsocketReadResult >, Detail::PromiseTypeBindFail< Error const & > > read_some(std::size_t limit=4096)
Reads something from the server.
Definition websocket_base.cpp:104
WebsocketBase(WebsocketBase const &)=delete
auto withStreamDo(FunctionT &&func)
Definition websocket_base.hpp:32
bool autoFragment() const
Returns true if the automatic fragmentation option is set.
Definition websocket_base.cpp:136
Detail::PromiseTypeBind< Detail::PromiseTypeBindThen< std::size_t >, Detail::PromiseTypeBindFail< Error const & > > send(std::string message)
Sends a string to the server.
Definition websocket_base.cpp:62
bool binary() const
Returns true if the binary message write option is set.
Definition websocket_base.cpp:54
boost::beast::basic_stream< boost::asio::ip::tcp, boost::asio::any_io_executor, boost::beast::simple_rate_policy > StreamType
Definition stream_type.hpp:11
Definition authorization.hpp:10
Definition promise_compat.hpp:67
Definition promise_compat.hpp:70