Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
receive_only_observer Class Reference

Partial observer that only handles receive events. More...

Inheritance diagram for receive_only_observer:
Inheritance graph
Collaboration diagram for receive_only_observer:
Collaboration graph

Public Member Functions

auto on_receive (std::span< const uint8_t > data) -> void override
 Called when data is received from the server.
 
- Public Member Functions inherited from kcenon::network::interfaces::null_connection_observer
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

Partial observer that only handles receive events.

Inherits from null_connection_observer so unneeded methods are no-ops.

Examples
observer_pattern.cpp.

Definition at line 89 of file observer_pattern.cpp.

Member Function Documentation

◆ on_receive()

auto receive_only_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.

Reimplemented from kcenon::network::interfaces::null_connection_observer.

Examples
observer_pattern.cpp.

Definition at line 91 of file observer_pattern.cpp.

91 {
92 std::string message(data.begin(), data.end());
93 std::cout << "[ReceiveOnly] Got: " << message << std::endl;
94 }

References kcenon::network::message.


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