Malloy
Loading...
Searching...
No Matches
Public Member Functions | List of all members
malloy::websocket::stream Class Reference

Websocket stream. May use TLS. More...

#include <stream.hpp>

Public Member Functions

 stream (detail::websocket_t &&ws)
 
 stream (boost::beast::websocket::stream< malloy::tcp::stream<> > &&s)
 
 stream (malloy::tcp::stream<> &&from)
 
 stream (detail::tls_stream &&ws)
 
 stream (boost::beast::ssl_stream< malloy::tcp::stream<> > &&from)
 
template<concepts::const_buffer_sequence Buff, detail::rw_completion_token Callback>
auto async_write (const Buff &buffers, Callback &&done)
 
template<concepts::const_buffer_sequence Buff>
auto write (const Buff &buffers) -> std::size_t
 
template<concepts::dynamic_buffer Buff, detail::rw_completion_token Callback>
auto async_read (Buff &buff, Callback &&done)
 
template<concepts::dynamic_buffer Buff>
auto read (Buff &buff, boost::beast::error_code &ec) -> std::size_t
 
template<boost::asio::completion_token_for< void(malloy::error_code)> CompletionToken>
auto async_close (boost::beast::websocket::close_reason why, CompletionToken &&done)
 
void set_option (auto &&opt)
 
template<typename Body , typename Fields , boost::asio::completion_token_for< void(malloy::error_code)> CompletionHandler>
auto async_accept (const boost::beast::http::request< Body, Fields > &req, CompletionHandler &&done)
 
template<typename Body , typename Fields >
auto accept (const boost::beast::http::request< Body, Fields > &req) -> boost::beast::error_code
 
template<boost::asio::completion_token_for< void(malloy::error_code)> Callback>
auto async_handshake (std::string host, std::string target, Callback &&done)
 
void set_binary (const bool enabled)
 Controls whether outgoing message will be indicated text or binary.
 
bool binary () const
 Checks whether outgoing messages will be indicated as text or binary.
 
template<typename Func >
void get_lowest_layer (Func &&visitor)
 Access get_lowest_layer of wrapped stream type.
 
auto get_executor ()
 Get executor of the underlying stream.
 
bool is_open () const
 Returns true if the stream is open.
 
constexpr bool is_tls () const
 Whether the underlying stream is TLS or not.
 
template<concepts::accept_handler Callback>
void async_handshake_tls (boost::asio::ssl::stream_base::handshake_type type, Callback &&done)
 

Detailed Description

Websocket stream. May use TLS.

Provides an interface for different types of websocket streams, allowing TLS and non-TLS streams to be used transparently.

Note
Not all of the interface has explicit documentation. You can assume that anything without documentation simply calls the function of the same name on the underlying stream

Member Function Documentation

◆ binary()

bool malloy::websocket::stream::binary ( ) const
inline

Checks whether outgoing messages will be indicated as text or binary.

Returns
Whether messages are indicated as binary.
See also
set_binary(bool)

◆ get_executor()

auto malloy::websocket::stream::get_executor ( )
inline

Get executor of the underlying stream.

Returns
s.get_executor() where s is any of the types in detail::websocket_t

◆ get_lowest_layer()

template<typename Func >
void malloy::websocket::stream::get_lowest_layer ( Func &&  visitor)
inline

Access get_lowest_layer of wrapped stream type.

Parameters
visitorVisitor function over boost::beast::get_lowest_layer(t) for t in detail::websocket_t

Example:

void set_expires(stream& s) {
s.get_lowest_layer([](auto& st) { st.expires_never(); });
}
Websocket stream. May use TLS.
Definition: stream.hpp:50
void get_lowest_layer(Func &&visitor)
Access get_lowest_layer of wrapped stream type.
Definition: stream.hpp:200

◆ is_open()

bool malloy::websocket::stream::is_open ( ) const
inline

Returns true if the stream is open.

The stream is open after a successful handshake, and when no error has occurred.

Returns
Whether the stream is open.

◆ is_tls()

constexpr bool malloy::websocket::stream::is_tls ( ) const
inlineconstexpr

Whether the underlying stream is TLS or not.

Note
Always false if MALLOY_FEATURE_TLS == 0

◆ set_binary()

void malloy::websocket::stream::set_binary ( const bool  enabled)
inline

Controls whether outgoing message will be indicated text or binary.

Parameters
enabledWhether to enable binary mode.
See also
binary()

The documentation for this class was generated from the following file: