![]() |
Kurlyk
|
Interface for a WebSocket client, providing methods for connection management, configuration, and event handling. More...
#include <IWebSocketClient.hpp>
Public Member Functions | |
IWebSocketClient ()=default | |
Default constructor. | |
virtual | ~IWebSocketClient ()=default |
Virtual destructor for safe cleanup in derived classes. | |
virtual std::function< void(std::unique_ptr< WebSocketEventData >)> & | event_handler ()=0 |
Accessor for the event handler function. | |
virtual std::function< void()> & | notify_handler ()=0 |
Accesses the notification handler for WebSocket events. | |
virtual void | set_config (std::unique_ptr< WebSocketConfig > config, std::function< void(bool)> callback)=0 |
Sets the configuration for the WebSocket client. | |
virtual void | connect (std::function< void(bool)> callback)=0 |
Initiates a connection to the WebSocket server. | |
virtual void | disconnect (std::function< void(bool)> callback)=0 |
Closes the connection to the WebSocket server. | |
virtual bool | is_running () const =0 |
Checks if the WebSocket client is actively running. | |
virtual std::list< std::unique_ptr< WebSocketEventData > > | receive_events () const =0 |
Retrieves all pending WebSocket events in a batch. | |
virtual std::unique_ptr< WebSocketEventData > | receive_event () const =0 |
Retrieves the next available WebSocket event, if any. | |
virtual void | process ()=0 |
Processes internal operations such as event handling and state updates. | |
virtual void | shutdown ()=0 |
Shuts down the WebSocket client, disconnecting and clearing all pending events. | |
![]() | |
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. | |
Interface for a WebSocket client, providing methods for connection management, configuration, and event handling.
Definition at line 12 of file IWebSocketClient.hpp.
|
default |
Default constructor.
|
virtualdefault |
Virtual destructor for safe cleanup in derived classes.
|
pure virtual |
Initiates a connection to the WebSocket server.
callback | Callback function to be executed upon connection completion, receiving a success status. |
Implemented in kurlyk::BaseWebSocketClient.
|
pure virtual |
Closes the connection to the WebSocket server.
callback | Callback function to be executed upon disconnection completion, receiving a success status. |
Implemented in kurlyk::BaseWebSocketClient.
|
pure virtual |
Accessor for the event handler function.
This method provides access to the event handler function used for handling WebSocket events. The returned reference allows getting or setting the function that will be called when a WebSocket event occurs.
std::function<void(std::unique_ptr<WebSocketEventData>)>
representing the event handler function. Implemented in kurlyk::BaseWebSocketClient.
|
pure virtual |
Checks if the WebSocket client is actively running.
Implemented in kurlyk::BaseWebSocketClient.
|
pure virtual |
Accesses the notification handler for WebSocket events.
The notification handler triggers the network worker to process WebSocket events by notifying it that an event has occurred, typically through NetworkWorker::get_instance().notify()
.
Implemented in kurlyk::BaseWebSocketClient.
|
pure virtual |
Processes internal operations such as event handling and state updates.
This function should be called periodically to ensure timely processing of internal state changes, events, and messages.
Implemented in kurlyk::BaseWebSocketClient.
|
pure virtual |
Retrieves the next available WebSocket event, if any.
This method supports event-by-event processing by returning the next event in the queue.
WebSocketEventData
object representing an event, or nullptr if no events are available. Implemented in kurlyk::BaseWebSocketClient.
|
pure virtual |
Retrieves all pending WebSocket events in a batch.
This method enables efficient processing of multiple accumulated events at once.
WebSocketEventData
objects representing the events. Implemented in kurlyk::BaseWebSocketClient.
|
pure virtual |
Sets the configuration for the WebSocket client.
config | A unique pointer to the WebSocket configuration object. |
callback | Callback function to be executed upon configuration completion. |
Implemented in kurlyk::BaseWebSocketClient.
|
pure virtual |
Shuts down the WebSocket client, disconnecting and clearing all pending events.
Initiates a disconnect event and processes any remaining events until the client stops running.
Implemented in kurlyk::BaseWebSocketClient.