26 explicit Client(std::reference_wrapper<Router> router);
53 void connect(const std::
string& host_ip,
int connection_port);
65 [[nodiscard]] std::
string get_uuid() const noexcept;
70 std::
string local_uuid_;
71 std::
string host_ip_{
"0.0.0.0"};
72 std::reference_wrapper<Router> router_;
73 ENetPeer* server_peer_{
nullptr};
74 ENetHost* client_{
nullptr};
77 void register_on_connect_handler() noexcept;
78 void register_on_disconnect_handler() noexcept;
79 void register_on_snapshot_full_handler() noexcept;
80 void register_on_snapshot_delta_handler() noexcept;
High-level ENet-based network client. Handles connecting, disconnecting, sending messages,...
Definition client.h:18
Client(std::reference_wrapper< Router > router)
Construct a Client with a shared Router.
void connect(const std::string &host_ip, int connection_port)
Initiates connection to a remote host.
std::string get_uuid() const noexcept
void poll() noexcept
Polls the network for incoming ENet events. Routes received messages and updates connection state.
~Client() noexcept
Safely destroys the client, unregisters handlers and frees ENet resources.
void send(const Message &message) noexcept
Sends a message to the connected server peer.
void disconnect() noexcept
Begins a clean disconnect by sending a disconnect message.
std::string get_host_ip() const noexcept
ConnectionState get_connection_state() const noexcept
Returns current connection state.
ConnectionState
Definition connection_state.h:4
Represents a complete network message including type and payload.
Definition network_message.h:105