69 virtual std::optional<HostNetworkEvent>
service(uint32_t timeout = 0) = 0;
77 virtual void broadcast(std::unique_ptr<IPacket> packet, uint8_t channelID = 0) = 0;
NetworkEventType
Type of network event.
@ RECEIVE
A packet was received.
@ CONNECT
A peer has connected.
@ DISCONNECT
A peer has disconnected.
Interface representing a network address (IP + port).
Interface representing a network host (server or client endpoint).
virtual std::optional< HostNetworkEvent > service(uint32_t timeout=0)=0
Service the host, processing network events.
virtual size_t getPeerCount() const =0
Get the number of connected peers.
virtual const IAddress & getAddress() const =0
Get the address this host is bound to.
virtual void flush()=0
Send all queued packets immediately.
virtual IPeer * connect(const IAddress &address, size_t channelCount=1, uint32_t data=0)=0
Connect to a remote host.
virtual void broadcast(std::unique_ptr< IPacket > packet, uint8_t channelID=0)=0
Broadcast a packet to all connected peers.
Interface representing a remote peer in the network.
Represents a network event (connection, disconnection, or received data).
NetworkEventType type
Type of the event.
uint32_t data
Additional data (e.g., disconnect reason).
std::unique_ptr< IPacket > packet
Packet received (only for RECEIVE events).
IPeer * peer
Peer associated with the event.
uint8_t channelID
Channel on which the event occurred.