10#ifndef NETWORK_CORE_UDP_H
11#define NETWORK_CORE_UDP_H
26 static constexpr bool value =
true;
Wrapper for network addresses.
std::vector< NetworkAddress > NetworkAddressList
Type for a list of addresses.
std::map< SOCKET, NetworkAddress > SocketList
Type for a mapping between address and socket.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
NetworkSocketHandler()=default
Create a new unbound socket.
void CloseSocket()
Close the actual UDP socket.
bool Listen()
Start listening on the given host and port.
SocketList sockets
The opened sockets.
void SendPacket(Packet &p, NetworkAddress &recv, bool all=false, bool broadcast=false)
Send a packet over UDP.
~NetworkUDPSocketHandler() override
On destructing of this class, the socket needs to be closed.
virtual void ReceiveServerResponse(Packet &p, NetworkAddress &client_addr)
Response to a query letting the client know we are here.
void ReceivePackets()
Receive a packet at UDP level.
NetworkUDPSocketHandler(NetworkAddressList *bind=nullptr)
Create an UDP socket but don't listen yet.
void ReceiveInvalidPacket(PacketUDPType, NetworkAddress &client_addr)
Helper for logging receiving invalid packets.
NetworkAddressList bind
The address to bind to.
virtual void ReceiveClientFindServer(Packet &p, NetworkAddress &client_addr)
Queries to the server for information about the game.
void HandleUDPPacket(Packet &p, NetworkAddress &client_addr)
Handle an incoming packets by sending it to the correct function.
Basic functions to create, fill and read packets.
static constexpr bool value
This is an enumeration of a PacketType.
Trait to mark an enumeration as a PacketType.
Internal entity of a packet.
PacketUDPType
Enum with all types of UDP packets.
@ ClientFindServer
Queries a game server for game information.
@ ServerResponse
Reply of the game server with game information.