|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Observer interface for client connection events. More...
#include <connection_observer.h>


Public Member Functions | |
| virtual | ~connection_observer ()=default |
| virtual auto | on_receive (std::span< const uint8_t > data) -> void=0 |
| Called when data is received from the server. | |
| virtual auto | on_connected () -> void=0 |
| Called when the connection is established. | |
| virtual auto | on_disconnected (std::optional< std::string_view > reason=std::nullopt) -> void=0 |
| Called when the connection is closed. | |
| virtual auto | on_error (std::error_code ec) -> void=0 |
| Called when an error occurs. | |
Observer interface for client connection events.
This interface provides a unified way to handle all connection-related events through the Observer pattern, replacing the individual callback setters (set_receive_callback, set_connected_callback, etc.).
Definition at line 75 of file connection_observer.h.
|
virtualdefault |
|
pure virtual |
Called when the connection is established.
This is called after a successful connection to the server.
Implemented in chat_observer, kcenon::network::interfaces::callback_adapter, and kcenon::network::interfaces::null_connection_observer.
|
pure virtual |
Called when the connection is closed.
| reason | Optional reason for the disconnection. |
The reason may be empty for normal disconnections.
Implemented in chat_observer, kcenon::network::interfaces::callback_adapter, and kcenon::network::interfaces::null_connection_observer.
|
pure virtual |
Called when an error occurs.
| ec | The error code describing the error. |
Implemented in chat_observer, kcenon::network::interfaces::callback_adapter, and kcenon::network::interfaces::null_connection_observer.
|
pure virtual |
Called when data is received from the server.
| data | The received data as a span of bytes. |
May be called from I/O threads. Implementation must be thread-safe.
Implemented in chat_observer, kcenon::network::interfaces::callback_adapter, kcenon::network::interfaces::null_connection_observer, and receive_only_observer.