Cadabra
Computer algebra system for field theory problems
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
websocket_client Class Reference

#include <websocket_client.hh>

Classes

struct  queued_message
 

Public Types

using message_handler = std::function< void(const std::string &)>
 
using connect_handler = std::function< void()>
 
using close_handler = std::function< void()>
 
using fail_handler = std::function< void(const boost::beast::error_code &)>
 

Public Member Functions

 websocket_client ()
 
 ~websocket_client ()
 
 websocket_client (const websocket_client &)=delete
 
websocket_clientoperator= (const websocket_client &)=delete
 
void set_message_handler (message_handler h)
 
void set_connect_handler (connect_handler h)
 
void set_close_handler (close_handler h)
 
void set_fail_handler (fail_handler h)
 
void connect (const std::string &uri)
 
void send (const std::string &message)
 
void close ()
 
void run ()
 
void stop ()
 

Private Member Functions

void on_resolve (const boost::beast::error_code &ec, boost::asio::ip::tcp::resolver::results_type results)
 
void on_connect (const boost::beast::error_code &ec)
 
void on_ssl_handshake (const boost::beast::error_code &ec)
 
void on_handshake (const boost::beast::error_code &ec)
 
void on_write (const boost::beast::error_code &ec, std::size_t bytes_transferred)
 
void on_read (const boost::beast::error_code &ec, std::size_t bytes_transferred)
 
void on_close (const boost::beast::error_code &ec)
 
void do_read ()
 
void do_write ()
 
void fail (const boost::beast::error_code &ec)
 

Private Attributes

boost::asio::io_context ioc_
 
boost::asio::ssl::context ssl_ctx_
 
boost::asio::ip::tcp::resolver resolver_
 
std::unique_ptr< boost::beast::websocket::stream< boost::beast::ssl_stream< boost::asio::ip::tcp::socket > > > wss_stream_
 
std::unique_ptr< boost::beast::websocket::stream< boost::asio::ip::tcp::socket > > ws_stream_
 
boost::beast::flat_buffer buffer_
 
bool is_ssl_
 
std::string host_
 
std::string port_
 
std::string path_
 
message_handler message_handler_
 
connect_handler connect_handler_
 
close_handler close_handler_
 
fail_handler fail_handler_
 
std::queue< queued_messagemessage_queue_
 
bool writing_ {false}
 

Member Typedef Documentation

◆ close_handler

using websocket_client::close_handler = std::function<void()>

◆ connect_handler

using websocket_client::connect_handler = std::function<void()>

◆ fail_handler

using websocket_client::fail_handler = std::function<void(const boost::beast::error_code&)>

◆ message_handler

using websocket_client::message_handler = std::function<void(const std::string&)>

Constructor & Destructor Documentation

◆ websocket_client() [1/2]

websocket_client::websocket_client ( )

◆ ~websocket_client()

websocket_client::~websocket_client ( )

◆ websocket_client() [2/2]

websocket_client::websocket_client ( const websocket_client )
delete

Member Function Documentation

◆ close()

void websocket_client::close ( )

◆ connect()

void websocket_client::connect ( const std::string &  uri)

◆ do_read()

void websocket_client::do_read ( )
private

◆ do_write()

void websocket_client::do_write ( )
private

◆ fail()

void websocket_client::fail ( const boost::beast::error_code &  ec)
private

◆ on_close()

void websocket_client::on_close ( const boost::beast::error_code &  ec)
private

◆ on_connect()

void websocket_client::on_connect ( const boost::beast::error_code &  ec)
private

◆ on_handshake()

void websocket_client::on_handshake ( const boost::beast::error_code &  ec)
private

◆ on_read()

void websocket_client::on_read ( const boost::beast::error_code &  ec,
std::size_t  bytes_transferred 
)
private

◆ on_resolve()

void websocket_client::on_resolve ( const boost::beast::error_code &  ec,
boost::asio::ip::tcp::resolver::results_type  results 
)
private

◆ on_ssl_handshake()

void websocket_client::on_ssl_handshake ( const boost::beast::error_code &  ec)
private

◆ on_write()

void websocket_client::on_write ( const boost::beast::error_code &  ec,
std::size_t  bytes_transferred 
)
private

◆ operator=()

websocket_client& websocket_client::operator= ( const websocket_client )
delete

◆ run()

void websocket_client::run ( )

◆ send()

void websocket_client::send ( const std::string &  message)

◆ set_close_handler()

void websocket_client::set_close_handler ( close_handler  h)

◆ set_connect_handler()

void websocket_client::set_connect_handler ( connect_handler  h)

◆ set_fail_handler()

void websocket_client::set_fail_handler ( fail_handler  h)

◆ set_message_handler()

void websocket_client::set_message_handler ( message_handler  h)

◆ stop()

void websocket_client::stop ( )

Member Data Documentation

◆ buffer_

boost::beast::flat_buffer websocket_client::buffer_
private

◆ close_handler_

close_handler websocket_client::close_handler_
private

◆ connect_handler_

connect_handler websocket_client::connect_handler_
private

◆ fail_handler_

fail_handler websocket_client::fail_handler_
private

◆ host_

std::string websocket_client::host_
private

◆ ioc_

boost::asio::io_context websocket_client::ioc_
private

◆ is_ssl_

bool websocket_client::is_ssl_
private

◆ message_handler_

message_handler websocket_client::message_handler_
private

◆ message_queue_

std::queue<queued_message> websocket_client::message_queue_
private

◆ path_

std::string websocket_client::path_
private

◆ port_

std::string websocket_client::port_
private

◆ resolver_

boost::asio::ip::tcp::resolver websocket_client::resolver_
private

◆ ssl_ctx_

boost::asio::ssl::context websocket_client::ssl_ctx_
private

◆ writing_

bool websocket_client::writing_ {false}
private

◆ ws_stream_

std::unique_ptr<boost::beast::websocket::stream<boost::asio::ip::tcp::socket> > websocket_client::ws_stream_
private

◆ wss_stream_

std::unique_ptr<boost::beast::websocket::stream<boost::beast::ssl_stream<boost::asio::ip::tcp::socket> > > websocket_client::wss_stream_
private

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