Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::interfaces::null_connection_observer Class Reference

No-op implementation of connection_observer. More...

#include <connection_observer.h>

Inheritance diagram for kcenon::network::interfaces::null_connection_observer:
Inheritance graph
Collaboration diagram for kcenon::network::interfaces::null_connection_observer:
Collaboration graph

Public Member Functions

auto on_receive (std::span< const uint8_t >) -> void override
 Called when data is received from the server.
 
auto on_connected () -> void override
 Called when the connection is established.
 
auto on_disconnected (std::optional< std::string_view >) -> void override
 Called when the connection is closed.
 
auto on_error (std::error_code) -> void override
 Called when an error occurs.
 
- Public Member Functions inherited from kcenon::network::interfaces::connection_observer
virtual ~connection_observer ()=default
 

Detailed Description

No-op implementation of connection_observer.

This class provides a default implementation that does nothing, useful as a placeholder or for connections that don't need all events.

Usage

// Use when you only need some events
class my_partial_observer : public null_connection_observer {
public:
void on_receive(std::span<const uint8_t> data) override {
// Only handle receive
}
};
No-op implementation of connection_observer.
auto on_receive(std::span< const uint8_t >) -> void override
Called when data is received from the server.
Examples
observer_pattern.cpp.

Definition at line 131 of file connection_observer.h.

Member Function Documentation

◆ on_connected()

auto kcenon::network::interfaces::null_connection_observer::on_connected ( ) -> void
inlineoverridevirtual

Called when the connection is established.

This is called after a successful connection to the server.

Implements kcenon::network::interfaces::connection_observer.

Definition at line 135 of file connection_observer.h.

135{}

◆ on_disconnected()

auto kcenon::network::interfaces::null_connection_observer::on_disconnected ( std::optional< std::string_view > reason) -> void
inlineoverridevirtual

Called when the connection is closed.

Parameters
reasonOptional reason for the disconnection.

Note

The reason may be empty for normal disconnections.

Implements kcenon::network::interfaces::connection_observer.

Definition at line 136 of file connection_observer.h.

136{}

◆ on_error()

auto kcenon::network::interfaces::null_connection_observer::on_error ( std::error_code ec) -> void
inlineoverridevirtual

Called when an error occurs.

Parameters
ecThe error code describing the error.

Implements kcenon::network::interfaces::connection_observer.

Definition at line 137 of file connection_observer.h.

137{}

◆ on_receive()

auto kcenon::network::interfaces::null_connection_observer::on_receive ( std::span< const uint8_t > data) -> void
inlineoverridevirtual

Called when data is received from the server.

Parameters
dataThe received data as a span of bytes.

Thread Safety

May be called from I/O threads. Implementation must be thread-safe.

Implements kcenon::network::interfaces::connection_observer.

Reimplemented in receive_only_observer.

Definition at line 134 of file connection_observer.h.

134{}

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