Kurlyk
Loading...
Searching...
No Matches
kurlyk::IWebSocketSender Class Referenceabstract

Interface for a WebSocket sender, offering methods to send messages, close connections, and check connection status. More...

#include <IWebSocketSender.hpp>

Inheritance diagram for kurlyk::IWebSocketSender:
kurlyk::IWebSocketClient kurlyk::BaseWebSocketClient kurlyk::SimpleWebSocketClientAdapter

Public Member Functions

 IWebSocketSender ()=default
 Default constructor for IWebSocketSender.
 
virtual ~IWebSocketSender ()=default
 Virtual destructor for IWebSocketSender.
 
virtual std::string get_http_version ()=0
 Retrieves the HTTP version used in the WebSocket connection.
 
virtual Headers get_headers ()=0
 Retrieves the headers associated with the WebSocket connection.
 
virtual std::string get_remote_endpoint ()=0
 Retrieves the remote endpoint information.
 
virtual bool send_message (const std::string &message, long rate_limit_id=0, std::function< void(const std::error_code &)> callback=nullptr)=0
 Sends a WebSocket message.
 
virtual bool send_close (int status=1000, const std::string &reason=std::string(), std::function< void(const std::error_code &)> callback=nullptr)=0
 Sends a close request to the WebSocket server.
 
virtual bool is_connected () const =0
 Checks if the WebSocket connection is currently active.
 

Detailed Description

Interface for a WebSocket sender, offering methods to send messages, close connections, and check connection status.

Definition at line 12 of file IWebSocketSender.hpp.

Constructor & Destructor Documentation

◆ IWebSocketSender()

kurlyk::IWebSocketSender::IWebSocketSender ( )
default

Default constructor for IWebSocketSender.

◆ ~IWebSocketSender()

virtual kurlyk::IWebSocketSender::~IWebSocketSender ( )
virtualdefault

Virtual destructor for IWebSocketSender.

Member Function Documentation

◆ get_headers()

virtual Headers kurlyk::IWebSocketSender::get_headers ( )
pure virtual

Retrieves the headers associated with the WebSocket connection.

Returns
A Headers object containing the HTTP headers.

Implemented in kurlyk::SimpleWebSocketClientAdapter.

◆ get_http_version()

virtual std::string kurlyk::IWebSocketSender::get_http_version ( )
pure virtual

Retrieves the HTTP version used in the WebSocket connection.

Returns
The HTTP version string.

Implemented in kurlyk::SimpleWebSocketClientAdapter.

◆ get_remote_endpoint()

virtual std::string kurlyk::IWebSocketSender::get_remote_endpoint ( )
pure virtual

Retrieves the remote endpoint information.

Returns
The remote endpoint as a string in the format "IP:Port".

Implemented in kurlyk::SimpleWebSocketClientAdapter.

◆ is_connected()

virtual bool kurlyk::IWebSocketSender::is_connected ( ) const
pure virtual

Checks if the WebSocket connection is currently active.

Returns
True if the WebSocket is connected, false otherwise.

Implemented in kurlyk::BaseWebSocketClient.

◆ send_close()

virtual bool kurlyk::IWebSocketSender::send_close ( int status = 1000,
const std::string & reason = std::string(),
std::function< void(const std::error_code &)> callback = nullptr )
pure virtual

Sends a close request to the WebSocket server.

Parameters
statusThe status code for the close request, default is 1000 (normal closure).
reasonOptional reason for closing the connection.
callbackOptional callback to execute once the close request is sent, providing an error code if any issues occur.
Returns
True if the close request was accepted, false otherwise.

◆ send_message()

virtual bool kurlyk::IWebSocketSender::send_message ( const std::string & message,
long rate_limit_id = 0,
std::function< void(const std::error_code &)> callback = nullptr )
pure virtual

Sends a WebSocket message.

Parameters
messageThe content of the message to be sent.
rate_limit_idThe ID of the rate limit to apply to this message. A value of 0 indicates the default or no rate limit.
callbackOptional callback to execute once the message is sent, providing an error code if any issues occur.
Returns
True if the message was accepted for sending, false otherwise.

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