High-level ENet-based network client. Handles connecting, disconnecting, sending messages, and routing received messages.
More...
#include <client.h>
|
| | Client (std::reference_wrapper< Router > router) |
| | Construct a Client with a shared Router.
|
| |
| | ~Client () noexcept |
| | Safely destroys the client, unregisters handlers and frees ENet resources.
|
| |
| void | poll () noexcept |
| | Polls the network for incoming ENet events. Routes received messages and updates connection state.
|
| |
| void | send (const Message &message) noexcept |
| | Sends a message to the connected server peer.
|
| |
| void | connect (const std::string &host_ip, int connection_port) |
| | Initiates connection to a remote host.
|
| |
| void | disconnect () noexcept |
| | Begins a clean disconnect by sending a disconnect message.
|
| |
| ConnectionState | get_connection_state () const noexcept |
| | Returns current connection state.
|
| |
| std::string | get_uuid () const noexcept |
| |
| std::string | get_host_ip () const noexcept |
| |
High-level ENet-based network client. Handles connecting, disconnecting, sending messages, and routing received messages.
The Client owns its ENetHost and manages lifecycle events. Incoming messages are forwarded through the Router for user-defined handling.
◆ Client()
| Client::Client |
( |
std::reference_wrapper< Router > |
router | ) |
|
|
explicit |
Construct a Client with a shared Router.
- Parameters
-
| router | Pointer to router used for dispatching messages. |
- Exceptions
-
| std::runtime_error | if ENet client host creation fails. |
◆ ~Client()
Safely destroys the client, unregisters handlers and frees ENet resources.
◆ connect()
| void Client::connect |
( |
const std::string & |
host_ip, |
|
|
int |
connection_port |
|
) |
| |
Initiates connection to a remote host.
- Parameters
-
| host_ip | Target IPv4/IPv6 address. |
| connection_port | Target port. |
- Exceptions
-
| std::runtime_error | if ENet cannot allocate a peer. |
◆ disconnect()
| void Client::disconnect |
( |
| ) |
|
|
noexcept |
Begins a clean disconnect by sending a disconnect message.
◆ get_connection_state()
Returns current connection state.
◆ get_host_ip()
| std::string Client::get_host_ip |
( |
| ) |
const |
|
noexcept |
◆ get_uuid()
| std::string Client::get_uuid |
( |
| ) |
const |
|
noexcept |
◆ poll()
Polls the network for incoming ENet events. Routes received messages and updates connection state.
◆ send()
| void Client::send |
( |
const Message & |
message | ) |
|
|
noexcept |
Sends a message to the connected server peer.
- Parameters
-
The documentation for this class was generated from the following file: