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

Classes

class  i_client
 

Functions

void setup_legacy_client (std::unique_ptr< i_client > client)
 Legacy client setup example.
 

Function Documentation

◆ setup_legacy_client()

void legacy_example::setup_legacy_client ( std::unique_ptr< i_client > client)

Legacy client setup example.

This demonstrates the OLD way of setting up a client:

  • Individual callback setters
  • Protocol-specific interface
  • std::vector<uint8_t> for data

Definition at line 74 of file legacy_client_example.cpp.

74 {
75 // OLD: Set callbacks individually (verbose)
76 client->set_receive_callback([](const std::vector<uint8_t>& data) {
77 std::cout << "[Legacy] Received " << data.size() << " bytes\n";
78 });
79
80 client->set_connected_callback([]() {
81 std::cout << "[Legacy] Connected!\n";
82 });
83
84 client->set_disconnected_callback([]() {
85 std::cout << "[Legacy] Disconnected\n";
86 });
87
88 client->set_error_callback([](std::error_code ec) {
89 std::cerr << "[Legacy] Error: " << ec.message() << "\n";
90 });
91
92 // OLD: Start with separate host and port
93 if (!client->start("localhost", 8080)) {
94 std::cerr << "[Legacy] Failed to connect\n";
95 return;
96 }
97
98 // OLD: Send using std::vector<uint8_t>
99 std::vector<uint8_t> data = {'H', 'e', 'l', 'l', 'o'};
100 client->send(std::move(data));
101}