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

Public sender abstraction used by WebSocketEventData::sender. 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 safe cleanup through the sender abstraction.
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 SubmitResult submit_message (const std::string &message, long rate_limit_id=0, std::function< void(const std::error_code &)> callback=nullptr)
 Attempts to submit a WebSocket message and reports the admission result.
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 SubmitResult submit_close (int status=1000, const std::string &reason=std::string(), std::function< void(const std::error_code &)> callback=nullptr)
 Attempts to submit a close request and reports the admission result.
virtual bool is_connected () const =0
 Checks if the WebSocket connection is currently active.

Detailed Description

Public sender abstraction used by WebSocketEventData::sender.

Allows event handlers to inspect connection metadata and send follow-up messages without knowing the backend type.

Definition at line 13 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 safe cleanup through the sender abstraction.

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.

◆ submit_close()

virtual SubmitResult kurlyk::IWebSocketSender::submit_close ( int status = 1000,
const std::string & reason = std::string(),
std::function< void(const std::error_code &)> callback = nullptr )
inlinevirtual

Attempts to submit a close request and reports the admission result.

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
SubmitResult describing whether the close request was accepted.

Definition at line 72 of file IWebSocketSender.hpp.

◆ submit_message()

virtual SubmitResult kurlyk::IWebSocketSender::submit_message ( const std::string & message,
long rate_limit_id = 0,
std::function< void(const std::error_code &)> callback = nullptr )
inlinevirtual

Attempts to submit a WebSocket message and reports the admission result.

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
SubmitResult describing whether the message was accepted for sending.

Definition at line 49 of file IWebSocketSender.hpp.


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