roar
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
Roar::WebsocketSession Class Reference

A WebsocketSession allows you to interact with a client via websocket protocol. More...

#include <websocket_session.hpp>

Collaboration diagram for Roar::WebsocketSession:

Classes

struct  Implementation
 

Public Member Functions

 WebsocketSession (std::variant< Detail::StreamType, boost::beast::ssl_stream< Detail::StreamType > > &&stream)
 
 ROAR_PIMPL_SPECIAL_FUNCTIONS_NO_MOVE (WebsocketSession)
 
Detail::PromiseTypeBind< Detail::PromiseTypeBindThen<>, Detail::PromiseTypeBindFail< Error const & > > accept (Request< boost::beast::http::empty_body > const &req)
 Accept an upgrade request and performs the necessary websocket handshake.
 
- Public Member Functions inherited from Roar::Detail::SharedFromBase< WebsocketBase, WebsocketSession >
std::shared_ptr< WebsocketSessionshared_from_this ()
 
- Public Member Functions inherited from Roar::WebsocketBase
 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.
 

Private Attributes

std::unique_ptr< Implementationimpl_
 

Additional Inherited Members

- Protected Attributes inherited from Roar::WebsocketBase
std::variant< boost::beast::websocket::stream< boost::beast::ssl_stream< Detail::StreamType > >, boost::beast::websocket::stream< Detail::StreamType > > ws_
 

Detailed Description

A WebsocketSession allows you to interact with a client via websocket protocol.

Constructor & Destructor Documentation

◆ WebsocketSession()

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

Member Function Documentation

◆ accept()

Detail::PromiseTypeBind< Detail::PromiseTypeBindThen<>, Detail::PromiseTypeBindFail< Error const & > > Roar::WebsocketSession::accept ( Request< boost::beast::http::empty_body > const &  req)

Accept an upgrade request and performs the necessary websocket handshake.

Parameters
reqAn http->ws upgrade request.

◆ ROAR_PIMPL_SPECIAL_FUNCTIONS_NO_MOVE()

Roar::WebsocketSession::ROAR_PIMPL_SPECIAL_FUNCTIONS_NO_MOVE ( WebsocketSession  )

Member Data Documentation

◆ impl_

std::unique_ptr<Implementation> Roar::WebsocketSession::impl_
private

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