OpenTTD
Public Member Functions | Protected Member Functions
MasterNetworkUDPSocketHandler Class Reference

*** Communication with the masterserver ***/ More...

Inheritance diagram for MasterNetworkUDPSocketHandler:
NetworkUDPSocketHandler NetworkSocketHandler

Public Member Functions

 MasterNetworkUDPSocketHandler (NetworkAddressList *addresses)
 Create the socket.
- Public Member Functions inherited from NetworkUDPSocketHandler
 NetworkUDPSocketHandler (NetworkAddressList *bind=NULL)
 Create an UDP socket but don't listen yet.
virtual ~NetworkUDPSocketHandler ()
 On destructing of this class, the socket needs to be closed.
bool Listen ()
 Start listening on the given host and port.
void Close ()
 Close the given UDP socket.
void SendPacket (Packet *p, NetworkAddress *recv, bool all=false, bool broadcast=false)
 Send a packet over UDP.
void ReceivePackets ()
 Receive a packet at UDP level.
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.
- Public Member Functions inherited from NetworkSocketHandler
 NetworkSocketHandler ()
 Create a new unbound socket.
virtual ~NetworkSocketHandler ()
 Close the socket when destructing the socket handler.
bool HasClientQuit () const
 Whether the current client connected to the socket has quit.
void Reopen ()
 Reopen the socket so we can send/receive stuff again.
void SendGRFIdentifier (Packet *p, const GRFIdentifier *grf)
 Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet.
void ReceiveGRFIdentifier (Packet *p, GRFIdentifier *grf)
 Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet.
void SendCompanyInformation (Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats, uint max_len=NETWORK_COMPANY_NAME_LENGTH)
 Package some generic company information into a packet.

Protected Member Functions

virtual void Receive_MASTER_ACK_REGISTER (Packet *p, NetworkAddress *client_addr)
 The master server acknowledges the registration.
virtual void Receive_MASTER_SESSION_KEY (Packet *p, NetworkAddress *client_addr)
 The master server sends us a session key.
- Protected Member Functions inherited from NetworkUDPSocketHandler
NetworkRecvStatus CloseConnection (bool error=true)
 Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just means the packet has to be dropped.
void ReceiveInvalidPacket (PacketUDPType, NetworkAddress *client_addr)
 Helper for logging receiving invalid packets.
virtual void Receive_CLIENT_FIND_SERVER (Packet *p, NetworkAddress *client_addr)
 Queries to the server for information about the game.
virtual void Receive_SERVER_RESPONSE (Packet *p, NetworkAddress *client_addr)
 Return of server information to the client.
virtual void Receive_CLIENT_DETAIL_INFO (Packet *p, NetworkAddress *client_addr)
 Query for detailed information about companies.
virtual void Receive_SERVER_DETAIL_INFO (Packet *p, NetworkAddress *client_addr)
 Reply with detailed company information.
virtual void Receive_SERVER_REGISTER (Packet *p, NetworkAddress *client_addr)
 Registers the server to the master server.
virtual void Receive_CLIENT_GET_LIST (Packet *p, NetworkAddress *client_addr)
 The client requests a list of servers.
virtual void Receive_MASTER_RESPONSE_LIST (Packet *p, NetworkAddress *client_addr)
 The server sends a list of servers.
virtual void Receive_SERVER_UNREGISTER (Packet *p, NetworkAddress *client_addr)
 A server unregisters itself at the master server.
virtual void Receive_CLIENT_GET_NEWGRFS (Packet *p, NetworkAddress *client_addr)
 The client requests information about some NewGRFs.
virtual void Receive_SERVER_NEWGRFS (Packet *p, NetworkAddress *client_addr)
 The server returns information about some NewGRFs.
void HandleUDPPacket (Packet *p, NetworkAddress *client_addr)
 Handle an incoming packets by sending it to the correct function.
virtual void HandleIncomingNetworkGameInfoGRFConfig (GRFConfig *config)
 Function that is called for every GRFConfig that is read when receiving a NetworkGameInfo.

Additional Inherited Members

- Protected Attributes inherited from NetworkUDPSocketHandler
NetworkAddressList bind
 The address to bind to.
SocketList sockets
 The opened sockets.

Detailed Description

*** Communication with the masterserver ***/

Helper class for connecting to the master server.

Definition at line 120 of file network_udp.cpp.

Constructor & Destructor Documentation

MasterNetworkUDPSocketHandler::MasterNetworkUDPSocketHandler ( NetworkAddressList addresses)
inline

Create the socket.

Parameters
addressesThe addresses to bind on.

Definition at line 129 of file network_udp.cpp.

Member Function Documentation

void MasterNetworkUDPSocketHandler::Receive_MASTER_ACK_REGISTER ( Packet p,
NetworkAddress client_addr 
)
protectedvirtual

The master server acknowledges the registration.

Parameters
pThe received packet.
client_addrThe origin of the packet.

Reimplemented from NetworkUDPSocketHandler.

Definition at line 133 of file network_udp.cpp.

References _network_advertise_retries, _settings_client, NetworkAddress::AddressFamilyAsString(), DEBUG, NetworkAddress::GetAddress(), ClientSettings::network, NetworkUDPRemoveAdvertise(), and NetworkSettings::server_advertise.

void MasterNetworkUDPSocketHandler::Receive_MASTER_SESSION_KEY ( Packet p,
NetworkAddress client_addr 
)
protectedvirtual

The master server sends us a session key.

uint64 The session key.

Parameters
pThe received packet.
client_addrThe origin of the packet.

Reimplemented from NetworkUDPSocketHandler.

Definition at line 142 of file network_udp.cpp.

References _session_key, NetworkAddress::AddressFamilyAsString(), DEBUG, NetworkAddress::GetAddress(), and Packet::Recv_uint64().


The documentation for this class was generated from the following file: