OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
12 #ifndef NETWORK_CORE_UDP_H
13 #define NETWORK_CORE_UDP_H
236 void Close()
override;
The game information that is sent from the server to the clients.
@ PACKET_UDP_CLIENT_GET_LIST
Request for serverlist from master server.
virtual void Receive_SERVER_UNREGISTER(Packet *p, NetworkAddress *client_addr)
A server unregisters itself at the master server.
@ PACKET_UDP_CLIENT_DETAIL_INFO
Queries a game server about details of the game, such as companies.
Base socket handler for all UDP sockets.
virtual void Receive_MASTER_SESSION_KEY(Packet *p, NetworkAddress *client_addr)
The master server sends us a session key.
@ PACKET_UDP_CLIENT_GET_NEWGRFS
Requests the name for a list of GRFs (GRF_ID and MD5)
virtual void Receive_MASTER_RESPONSE_LIST(Packet *p, NetworkAddress *client_addr)
The server sends a list of servers.
ServerListType
The types of server lists we can get.
SocketHandler for all network sockets in OpenTTD.
@ PACKET_UDP_CLIENT_FIND_SERVER
Queries a game server for game information.
@ PACKET_UDP_SERVER_UNREGISTER
Request to be removed from the server-list.
@ PACKET_UDP_SERVER_REGISTER
Packet to register itself to the master server.
NetworkRecvStatus CloseConnection(bool error=true) override
Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just ...
void Close() override
Close the given UDP socket.
virtual void Receive_SERVER_NEWGRFS(Packet *p, NetworkAddress *client_addr)
The server returns information about some NewGRFs.
NetworkUDPSocketHandler(NetworkAddressList *bind=nullptr)
Create an UDP socket but don't listen yet.
virtual void Receive_SERVER_REGISTER(Packet *p, NetworkAddress *client_addr)
Registers the server to the master server.
@ SLT_IPv6
Get the IPv6 addresses.
virtual void Receive_CLIENT_FIND_SERVER(Packet *p, NetworkAddress *client_addr)
Queries to the server for information about the game.
@ PACKET_UDP_MASTER_SESSION_KEY
Sends a fresh session key to the client.
virtual void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config)
Function that is called for every GRFConfig that is read when receiving a NetworkGameInfo.
virtual ~NetworkUDPSocketHandler()
On destructing of this class, the socket needs to be closed.
virtual void Receive_SERVER_DETAIL_INFO(Packet *p, NetworkAddress *client_addr)
Reply with detailed company information.
Information about GRF, used in the game and (part of it) in savegames.
std::vector< NetworkAddress > NetworkAddressList
Type for a list of addresses.
virtual void Receive_CLIENT_GET_NEWGRFS(Packet *p, NetworkAddress *client_addr)
The client requests information about some NewGRFs.
SocketList sockets
The opened sockets.
@ PACKET_UDP_END
Must ALWAYS be on the end of this list!! (period)
NetworkAddressList bind
The address to bind to.
@ PACKET_UDP_MASTER_ACK_REGISTER
Packet indicating registration has succeeded.
@ PACKET_UDP_SERVER_DETAIL_INFO
Reply of the game server about details of the game, such as companies.
void SendNetworkGameInfo(Packet *p, const NetworkGameInfo *info)
Serializes the NetworkGameInfo struct to the packet.
void ReceiveNetworkGameInfo(Packet *p, NetworkGameInfo *info)
Deserializes the NetworkGameInfo struct from the packet.
@ SLT_END
End of 'arrays' marker.
@ SLT_IPv4
Get the IPv4 addresses.
Internal entity of a packet.
void ReceiveInvalidPacket(PacketUDPType, NetworkAddress *client_addr)
Helper for logging receiving invalid packets.
@ PACKET_UDP_SERVER_NEWGRFS
Sends the list of NewGRF's requested.
@ PACKET_UDP_SERVER_RESPONSE
Reply of the game server with game information.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
virtual void Receive_MASTER_ACK_REGISTER(Packet *p, NetworkAddress *client_addr)
The master server acknowledges the registration.
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
void HandleUDPPacket(Packet *p, NetworkAddress *client_addr)
Handle an incoming packets by sending it to the correct function.
bool Listen()
Start listening on the given host and port.
@ SLT_AUTODETECT
Autodetect the type based on the connection.
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
virtual void Receive_CLIENT_GET_LIST(Packet *p, NetworkAddress *client_addr)
The client requests a list of servers.
@ PACKET_UDP_MASTER_RESPONSE_LIST
Response from master server with server ip's + port's.
virtual void Receive_CLIENT_DETAIL_INFO(Packet *p, NetworkAddress *client_addr)
Query for detailed information about companies.
void ReceivePackets()
Receive a packet at UDP level.
virtual void Receive_SERVER_RESPONSE(Packet *p, NetworkAddress *client_addr)
Return of server information to the client.
PacketUDPType
Enum with all types of UDP packets.
void SendPacket(Packet *p, NetworkAddress *recv, bool all=false, bool broadcast=false)
Send a packet over UDP.