|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Base interface for client-side network components. More...
#include <i_client.h>


Public Types | |
| using | receive_callback_t = std::function<void(const std::vector<uint8_t>&)> |
| Callback type for received data. | |
| using | connected_callback_t = std::function<void()> |
| Callback type for connection established. | |
| using | disconnected_callback_t = std::function<void()> |
| Callback type for disconnection. | |
| using | error_callback_t = std::function<void(std::error_code)> |
| Callback type for errors. | |
Public Member Functions | |
| virtual auto | start (std::string_view host, uint16_t port) -> VoidResult=0 |
| Starts the client and connects to the specified server. | |
| virtual auto | stop () -> VoidResult=0 |
| Stops the client and closes the connection. | |
| virtual auto | send (std::vector< uint8_t > &&data) -> VoidResult=0 |
| Sends data to the connected server. | |
| virtual auto | is_connected () const -> bool=0 |
| Checks if the client is connected to the server. | |
| virtual auto | set_observer (std::shared_ptr< connection_observer > observer) -> void=0 |
| Sets the connection observer for unified event handling. | |
| virtual auto | set_receive_callback (receive_callback_t callback) -> void=0 |
| Sets the callback for received data. | |
| 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. | |
Base interface for client-side network components.
This interface extends i_network_component with client-specific operations such as connecting to a server, sending data, and handling connection state.
Use set_observer() with a connection_observer implementation for unified event handling. See connection_observer.h for details.
Definition at line 51 of file i_client.h.
| using kcenon::network::interfaces::i_client::connected_callback_t = std::function<void()> |
Callback type for connection established.
Definition at line 57 of file i_client.h.
| using kcenon::network::interfaces::i_client::disconnected_callback_t = std::function<void()> |
Callback type for disconnection.
Definition at line 59 of file i_client.h.
| using kcenon::network::interfaces::i_client::error_callback_t = std::function<void(std::error_code)> |
Callback type for errors.
Definition at line 61 of file i_client.h.
| using kcenon::network::interfaces::i_client::receive_callback_t = std::function<void(const std::vector<uint8_t>&)> |
Callback type for received data.
Definition at line 55 of file i_client.h.
|
nodiscardpure virtual |
|
nodiscardpure virtual |
|
pure virtual |
Sets the callback for connection established.
| callback | The callback function. |
|
pure virtual |
Sets the callback for disconnection.
| callback | The callback function. |
|
pure virtual |
Sets the callback for errors.
| callback | The callback function. |
|
pure virtual |
Sets the connection observer for unified event handling.
| observer | The observer instance (shared ownership). |
The observer receives all connection events through a single interface, replacing the need for individual callback setters.
Thread-safe. Observer methods may be invoked from I/O threads.
|
pure virtual |
|
nodiscardpure virtual |
Starts the client and connects to the specified server.
| host | The server hostname or IP address. |
| port | The server port number. |
Thread-safe. Only one start operation can succeed at a time.
|
nodiscardpure virtual |