roar
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Roar::WebsocketBase Class Reference

#include <websocket_base.hpp>

Collaboration diagram for Roar::WebsocketBase:

Public Member Functions

 WebsocketBase (std::variant< Detail::StreamType, boost::beast::ssl_stream< Detail::StreamType > > &&stream)
 
 WebsocketBase (std::variant< boost::beast::websocket::stream< boost::beast::ssl_stream< Detail::StreamType > >, boost::beast::websocket::stream< Detail::StreamType > > &&ws)
 
 WebsocketBase (WebsocketBase &&)=delete
 
WebsocketBaseoperator= (WebsocketBase &&)=delete
 
 WebsocketBase (WebsocketBase const &)=delete
 
WebsocketBaseoperator= (WebsocketBase const &)=delete
 
virtual ~WebsocketBase ()
 
template<typename FunctionT >
auto withStreamDo (FunctionT &&func)
 
template<typename FunctionT >
auto withStreamDo (FunctionT &&func) const
 
void readMessageMax (std::size_t amount)
 Set the maximum incoming message size option.
 
std::size_t readMessageMax () const
 Returns the maximum incoming message size setting.
 
void binary (bool enable)
 Enable/Disable binary for next send message.
 
bool binary () const
 Returns true if the binary message write option is set.
 
Detail::PromiseTypeBind< Detail::PromiseTypeBindThen< std::size_t >, Detail::PromiseTypeBindFail< Error const & > > send (std::string message)
 Sends a string to the server.
 
Detail::PromiseTypeBind< Detail::PromiseTypeBindThen< WebsocketReadResult >, Detail::PromiseTypeBindFail< Error const & > > read ()
 Reads something from the server.
 
Detail::PromiseTypeBind< Detail::PromiseTypeBindThen< WebsocketReadResult >, Detail::PromiseTypeBindFail< Error const & > > read_some (std::size_t limit=4096)
 Reads something from the server.
 
void autoFragment (bool enable)
 Set the automatic fragmentation option.
 
bool autoFragment () const
 Returns true if the automatic fragmentation option is set.
 
bool close (std::chrono::seconds closeWaitTimeout=std::chrono::seconds{3})
 Closes the websocket connection.
 

Protected Attributes

std::variant< boost::beast::websocket::stream< boost::beast::ssl_stream< Detail::StreamType > >, boost::beast::websocket::stream< Detail::StreamType > > ws_
 

Constructor & Destructor Documentation

◆ WebsocketBase() [1/4]

Roar::WebsocketBase::WebsocketBase ( std::variant< Detail::StreamType, boost::beast::ssl_stream< Detail::StreamType > > &&  stream)

◆ WebsocketBase() [2/4]

Roar::WebsocketBase::WebsocketBase ( std::variant< boost::beast::websocket::stream< boost::beast::ssl_stream< Detail::StreamType > >, boost::beast::websocket::stream< Detail::StreamType > > &&  ws)

◆ WebsocketBase() [3/4]

Roar::WebsocketBase::WebsocketBase ( WebsocketBase &&  )
delete

◆ WebsocketBase() [4/4]

Roar::WebsocketBase::WebsocketBase ( WebsocketBase const &  )
delete

◆ ~WebsocketBase()

Roar::WebsocketBase::~WebsocketBase ( )
virtualdefault

Member Function Documentation

◆ autoFragment() [1/2]

bool Roar::WebsocketBase::autoFragment ( ) const

Returns true if the automatic fragmentation option is set.

Returns
true yes is set
false no is not.

◆ autoFragment() [2/2]

void Roar::WebsocketBase::autoFragment ( bool  enable)

Set the automatic fragmentation option.

Parameters
enabletrue = automatic fragmentation, false = no automatic fragmentation.

◆ binary() [1/2]

bool Roar::WebsocketBase::binary ( ) const

Returns true if the binary message write option is set.

Returns
true binary is set.
false binary is not set.

◆ binary() [2/2]

void Roar::WebsocketBase::binary ( bool  enable)

Enable/Disable binary for next send message.

Parameters
enabletrue = binary yes, false = binary no.

◆ close()

bool Roar::WebsocketBase::close ( std::chrono::seconds  closeWaitTimeout = std::chrono::seconds{3})

Closes the websocket connection.

Returns
true Returns true when the timeout was not reached.
false Returns false when the timeout was reached.

◆ operator=() [1/2]

WebsocketBase & Roar::WebsocketBase::operator= ( WebsocketBase &&  )
delete

◆ operator=() [2/2]

WebsocketBase & Roar::WebsocketBase::operator= ( WebsocketBase const &  )
delete

◆ read()

Reads something from the server.

Returns
A promise to continue after reading

◆ read_some()

Detail::PromiseTypeBind< Detail::PromiseTypeBindThen< WebsocketReadResult >, Detail::PromiseTypeBindFail< Error const & > > Roar::WebsocketBase::read_some ( std::size_t  limit = 4096)

Reads something from the server.

Parameters
limitA limit on how much to read.
Returns
A promise to continue after reading

◆ readMessageMax() [1/2]

std::size_t Roar::WebsocketBase::readMessageMax ( ) const

Returns the maximum incoming message size setting.

Returns
std::size_t

◆ readMessageMax() [2/2]

void Roar::WebsocketBase::readMessageMax ( std::size_t  amount)

Set the maximum incoming message size option.

Parameters
amount

◆ send()

Detail::PromiseTypeBind< Detail::PromiseTypeBindThen< std::size_t >, Detail::PromiseTypeBindFail< Error const & > > Roar::WebsocketBase::send ( std::string  message)

Sends a string to the server.

Parameters
messageA message to send.
Returns
A promise that is called with the amount of bytes sent, Promise::fail with a Roar::Error.

◆ withStreamDo() [1/2]

template<typename FunctionT >
auto Roar::WebsocketBase::withStreamDo ( FunctionT &&  func)
inline

◆ withStreamDo() [2/2]

template<typename FunctionT >
auto Roar::WebsocketBase::withStreamDo ( FunctionT &&  func) const
inline

Member Data Documentation

◆ ws_

std::variant< boost::beast::websocket::stream<boost::beast::ssl_stream<Detail::StreamType> >, boost::beast::websocket::stream<Detail::StreamType> > Roar::WebsocketBase::ws_
protected

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