35 std::cout <<
"=== Unified Messaging Interface Example ===" << std::endl;
38 std::cout <<
"\n1. Endpoint configuration:" << std::endl;
40 server_endpoint.
host =
"0.0.0.0";
41 server_endpoint.
port = 9090;
44 client_endpoint.
host =
"localhost";
45 client_endpoint.
port = 9090;
47 std::cout <<
" Server: " << server_endpoint.
host <<
":" << server_endpoint.
port << std::endl;
48 std::cout <<
" Client: " << client_endpoint.
host <<
":" << client_endpoint.
port << std::endl;
51 std::cout <<
"\n2. Setting up connection callbacks:" << std::endl;
55 { std::cout <<
" [Callback] Connected!" << std::endl; };
57 callbacks.
on_data = [](std::span<const std::byte> data)
58 { std::cout <<
" [Callback] Received " << data.size() <<
" bytes" << std::endl; };
62 std::cout <<
" [Callback] Disconnected";
65 std::cout <<
": " << *reason;
67 std::cout << std::endl;
70 callbacks.
on_error = [](std::error_code ec)
71 { std::cout <<
" [Callback] Error: " << ec.message() << std::endl; };
73 std::cout <<
" All 4 callbacks configured (on_connected, on_data, "
74 <<
"on_disconnected, on_error)" << std::endl;
77 std::cout <<
"\n3. Unified interface hierarchy:" << std::endl;
78 std::cout <<
" i_transport - send(), is_connected(), remote_endpoint()" << std::endl;
79 std::cout <<
" i_connection - connect(), close(), set_callbacks()" << std::endl;
80 std::cout <<
" i_listener - start(), stop(), set_accept_callback()" << std::endl;
81 std::cout <<
"\n Use with protocol tags:" << std::endl;
82 std::cout <<
" unified_messaging_client<tcp_protocol, no_tls>" << std::endl;
83 std::cout <<
" unified_messaging_server<tcp_protocol, tls_enabled>" << std::endl;
85 std::cout <<
"\nDone." << std::endl;
Main namespace for all Network System components.
Callback functions for connection events.
std::function< void()> on_disconnected
Called when connection is closed.
std::function< void(std::span< const std::byte >)> on_data
Called when data is received (raw bytes)
std::function< void()> on_connected
Called when connection is established.
std::function< void(std::error_code)> on_error
Called when an error occurs.
Network endpoint information (host/port or URL)
std::string host
Hostname, IP address, or full URL.
uint16_t port
Port number (0 if embedded in URL)
Convenience header for the unified network interface API.