|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Interface for WebSocket client components. More...
#include <i_websocket_client.h>


Public Types | |
| using | text_callback_t = std::function<void(const std::string&)> |
| Callback type for text messages. | |
| using | binary_callback_t = std::function<void(const std::vector<uint8_t>&)> |
| Callback type for binary messages. | |
| using | connected_callback_t = std::function<void()> |
| Callback type for connection established. | |
| using | disconnected_callback_t = std::function<void(uint16_t code, std::string_view reason)> |
| Callback type for disconnection (with close code and reason) | |
| using | error_callback_t = std::function<void(std::error_code)> |
| Callback type for errors. | |
| using | send_callback_t = std::function<void(std::error_code, std::size_t)> |
| Callback type for send completion. | |
Public Member Functions | |
| virtual auto | start (std::string_view host, uint16_t port, std::string_view path="/") -> VoidResult=0 |
| Starts the WebSocket client connecting to the specified endpoint. | |
| virtual auto | stop () -> VoidResult=0 |
| Stops the WebSocket client. | |
| virtual auto | is_connected () const -> bool=0 |
| Checks if the WebSocket connection is established. | |
| virtual auto | send_text (std::string &&message, send_callback_t handler=nullptr) -> VoidResult=0 |
| Sends a text message. | |
| virtual auto | send_binary (std::vector< uint8_t > &&data, send_callback_t handler=nullptr) -> VoidResult=0 |
| Sends a binary message. | |
| virtual auto | ping (std::vector< uint8_t > &&payload={}) -> VoidResult=0 |
| Sends a ping frame. | |
| virtual auto | close (uint16_t code=1000, std::string_view reason="") -> VoidResult=0 |
| Closes the WebSocket connection gracefully. | |
| virtual auto | set_text_callback (text_callback_t callback) -> void=0 |
| Sets the callback for text messages. | |
| virtual auto | set_binary_callback (binary_callback_t callback) -> void=0 |
| Sets the callback for binary messages. | |
| virtual auto | set_connected_callback (connected_callback_t callback) -> void=0 |
| Sets the callback for connection established. | |
| virtual auto | set_disconnected_callback (disconnected_callback_t callback) -> void=0 |
| Sets the callback for disconnection. | |
| virtual auto | set_error_callback (error_callback_t callback) -> void=0 |
| Sets the callback for errors. | |
Public Member Functions inherited from kcenon::network::interfaces::i_network_component | |
| virtual | ~i_network_component ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
| i_network_component (const i_network_component &)=delete | |
| i_network_component & | operator= (const i_network_component &)=delete |
| i_network_component (i_network_component &&)=delete | |
| i_network_component & | operator= (i_network_component &&)=delete |
Additional Inherited Members | |
Protected Member Functions inherited from kcenon::network::interfaces::i_network_component | |
| i_network_component ()=default | |
| Default constructor (only for derived classes) | |
| virtual auto | is_running () const -> bool=0 |
| Checks if the component is currently running. | |
| virtual auto | wait_for_stop () -> void=0 |
| Blocks until the component has stopped. | |
Interface for WebSocket client components.
This interface extends i_network_component with WebSocket-specific operations such as text/binary message sending, path-based connections, and close frame handling.
Definition at line 41 of file i_websocket_client.h.
| using kcenon::network::interfaces::i_websocket_client::binary_callback_t = std::function<void(const std::vector<uint8_t>&)> |
Callback type for binary messages.
Definition at line 48 of file i_websocket_client.h.
| using kcenon::network::interfaces::i_websocket_client::connected_callback_t = std::function<void()> |
Callback type for connection established.
Definition at line 51 of file i_websocket_client.h.
| using kcenon::network::interfaces::i_websocket_client::disconnected_callback_t = std::function<void(uint16_t code, std::string_view reason)> |
Callback type for disconnection (with close code and reason)
Definition at line 54 of file i_websocket_client.h.
| using kcenon::network::interfaces::i_websocket_client::error_callback_t = std::function<void(std::error_code)> |
Callback type for errors.
Definition at line 57 of file i_websocket_client.h.
| using kcenon::network::interfaces::i_websocket_client::send_callback_t = std::function<void(std::error_code, std::size_t)> |
Callback type for send completion.
Definition at line 60 of file i_websocket_client.h.
| using kcenon::network::interfaces::i_websocket_client::text_callback_t = std::function<void(const std::string&)> |
Callback type for text messages.
Definition at line 45 of file i_websocket_client.h.
|
nodiscardpure virtual |
Closes the WebSocket connection gracefully.
| code | The close status code. |
| reason | Optional human-readable reason. |
Implemented in kcenon::network::core::messaging_ws_client.
|
nodiscardpure virtual |
Checks if the WebSocket connection is established.
Implemented in kcenon::network::core::messaging_ws_client.
|
nodiscardpure virtual |
Sends a ping frame.
| payload | Optional payload data (max 125 bytes). |
Implemented in kcenon::network::core::messaging_ws_client.
|
nodiscardpure virtual |
Sends a binary message.
| data | The binary data to send. |
| handler | Optional completion handler. |
Implemented in kcenon::network::core::messaging_ws_client.
|
nodiscardpure virtual |
Sends a text message.
| message | The text message to send. |
| handler | Optional completion handler. |
Implemented in kcenon::network::core::messaging_ws_client.
|
pure virtual |
Sets the callback for binary messages.
| callback | The callback function. |
Implemented in kcenon::network::core::messaging_ws_client.
|
pure virtual |
Sets the callback for connection established.
| callback | The callback function. |
Implemented in kcenon::network::core::messaging_ws_client.
|
pure virtual |
Sets the callback for disconnection.
| callback | The callback function. |
Implemented in kcenon::network::core::messaging_ws_client.
|
pure virtual |
Sets the callback for errors.
| callback | The callback function. |
Implemented in kcenon::network::core::messaging_ws_client.
|
pure virtual |
Sets the callback for text messages.
| callback | The callback function. |
Implemented in kcenon::network::core::messaging_ws_client.
|
nodiscardpure virtual |
Starts the WebSocket client connecting to the specified endpoint.
| host | The server hostname or IP address. |
| port | The server port number. |
| path | The WebSocket path (default: "/"). |
Thread-safe. Only one start operation can succeed at a time.
Implemented in kcenon::network::core::messaging_ws_client.
|
nodiscardpure virtual |
Stops the WebSocket client.
Performs graceful close if connected.
Thread-safe.
Implemented in kcenon::network::core::messaging_ws_client.