Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::unified::connection_callbacks Struct Reference

Callback functions for connection events. More...

#include <types.h>

Collaboration diagram for kcenon::network::unified::connection_callbacks:
Collaboration graph

Public Attributes

std::function< void()> on_connected
 Called when connection is established.
 
std::function< void(std::span< const std::byte >)> on_data
 Called when data is received (raw bytes)
 
std::function< void()> on_disconnected
 Called when connection is closed.
 
std::function< void(std::error_code)> on_error
 Called when an error occurs.
 

Detailed Description

Callback functions for connection events.

Groups all callback functions that can be registered for connection lifecycle events. All callbacks are optional (can be empty).

Thread Safety

Callbacks may be invoked from I/O threads. Implementations must ensure their callbacks are thread-safe if they access shared state.

Examples

cbs.on_connected = []() {
std::cout << "Connected!" << std::endl;
};
cbs.on_data = [](std::span<const std::byte> data) {
// Process received data
};
cbs.on_disconnected = []() {
std::cout << "Disconnected!" << std::endl;
};
cbs.on_error = [](std::error_code ec) {
std::cerr << "Error: " << ec.message() << std::endl;
};
Callback functions for connection events.
Definition types.h:154
std::function< void()> on_disconnected
Called when connection is closed.
Definition types.h:162
std::function< void(std::span< const std::byte >)> on_data
Called when data is received (raw bytes)
Definition types.h:159
std::function< void()> on_connected
Called when connection is established.
Definition types.h:156
std::function< void(std::error_code)> on_error
Called when an error occurs.
Definition types.h:165
Examples
unified_messaging_example.cpp.

Definition at line 154 of file types.h.

Member Data Documentation

◆ on_connected

std::function<void()> kcenon::network::unified::connection_callbacks::on_connected

Called when connection is established.

Examples
unified_messaging_example.cpp.

Definition at line 156 of file types.h.

Referenced by main().

◆ on_data

std::function<void(std::span<const std::byte>)> kcenon::network::unified::connection_callbacks::on_data

Called when data is received (raw bytes)

Examples
unified_messaging_example.cpp.

Definition at line 159 of file types.h.

Referenced by main().

◆ on_disconnected

std::function<void()> kcenon::network::unified::connection_callbacks::on_disconnected

Called when connection is closed.

Examples
unified_messaging_example.cpp.

Definition at line 162 of file types.h.

Referenced by kcenon::network::unified::adapters::udp_connection_adapter::close(), and main().

◆ on_error

std::function<void(std::error_code)> kcenon::network::unified::connection_callbacks::on_error

Called when an error occurs.

Examples
unified_messaging_example.cpp.

Definition at line 165 of file types.h.

Referenced by main().


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