OpenTTD
|
*** Communication with clients (we are server) ***/ More...
Public Member Functions | |
ServerNetworkUDPSocketHandler (NetworkAddressList *addresses) | |
Create the socket. More... | |
![]() | |
NetworkUDPSocketHandler (NetworkAddressList *bind=NULL) | |
Create an UDP socket but don't listen yet. More... | |
virtual | ~NetworkUDPSocketHandler () |
On destructing of this class, the socket needs to be closed. | |
bool | Listen () |
Start listening on the given host and port. More... | |
void | Close () |
Close the given UDP socket. | |
void | SendPacket (Packet *p, NetworkAddress *recv, bool all=false, bool broadcast=false) |
Send a packet over UDP. More... | |
void | ReceivePackets () |
Receive a packet at UDP level. | |
void | SendNetworkGameInfo (Packet *p, const NetworkGameInfo *info) |
Serializes the NetworkGameInfo struct to the packet. More... | |
void | ReceiveNetworkGameInfo (Packet *p, NetworkGameInfo *info) |
Deserializes the NetworkGameInfo struct from the packet. More... | |
![]() | |
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. More... | |
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. More... | |
void | ReceiveGRFIdentifier (Packet *p, GRFIdentifier *grf) |
Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet. More... | |
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. More... | |
Protected Member Functions | |
virtual void | Receive_CLIENT_FIND_SERVER (Packet *p, NetworkAddress *client_addr) |
Queries to the server for information about the game. More... | |
virtual void | Receive_CLIENT_DETAIL_INFO (Packet *p, NetworkAddress *client_addr) |
Query for detailed information about companies. More... | |
virtual void | Receive_CLIENT_GET_NEWGRFS (Packet *p, NetworkAddress *client_addr) |
A client has requested the names of some NewGRFs. More... | |
![]() | |
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. More... | |
void | ReceiveInvalidPacket (PacketUDPType, NetworkAddress *client_addr) |
Helper for logging receiving invalid packets. More... | |
virtual void | Receive_SERVER_RESPONSE (Packet *p, NetworkAddress *client_addr) |
Return of server information to the client. More... | |
virtual void | Receive_SERVER_DETAIL_INFO (Packet *p, NetworkAddress *client_addr) |
Reply with detailed company information. More... | |
virtual void | Receive_SERVER_REGISTER (Packet *p, NetworkAddress *client_addr) |
Registers the server to the master server. More... | |
virtual void | Receive_MASTER_ACK_REGISTER (Packet *p, NetworkAddress *client_addr) |
The master server acknowledges the registration. More... | |
virtual void | Receive_CLIENT_GET_LIST (Packet *p, NetworkAddress *client_addr) |
The client requests a list of servers. More... | |
virtual void | Receive_MASTER_RESPONSE_LIST (Packet *p, NetworkAddress *client_addr) |
The server sends a list of servers. More... | |
virtual void | Receive_SERVER_UNREGISTER (Packet *p, NetworkAddress *client_addr) |
A server unregisters itself at the master server. More... | |
virtual void | Receive_SERVER_NEWGRFS (Packet *p, NetworkAddress *client_addr) |
The server returns information about some NewGRFs. More... | |
virtual void | Receive_MASTER_SESSION_KEY (Packet *p, NetworkAddress *client_addr) |
The master server sends us a session key. More... | |
void | HandleUDPPacket (Packet *p, NetworkAddress *client_addr) |
Handle an incoming packets by sending it to the correct function. More... | |
virtual void | HandleIncomingNetworkGameInfoGRFConfig (GRFConfig *config) |
Function that is called for every GRFConfig that is read when receiving a NetworkGameInfo. More... | |
Additional Inherited Members | |
![]() | |
NetworkAddressList | bind |
The address to bind to. More... | |
SocketList | sockets |
The opened sockets. More... | |
*** Communication with clients (we are server) ***/
Helper class for handling all server side communication.
Definition at line 151 of file network_udp.cpp.
|
inline |
Create the socket.
addresses | The addresses to bind on. |
Definition at line 161 of file network_udp.cpp.
|
protectedvirtual |
Query for detailed information about companies.
p | The received packet. |
client_addr | The origin of the packet. |
Reimplemented from NetworkUDPSocketHandler.
Definition at line 205 of file network_udp.cpp.
References _network_udp_server, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetNumItems(), MAX_COMPANIES, NETWORK_COMPANY_INFO_VERSION, NETWORK_COMPANY_NAME_LENGTH, NetworkPopulateCompanyStats(), PACKET_UDP_SERVER_DETAIL_INFO, SEND_MTU, Packet::Send_uint8(), and Packet::size.
|
protectedvirtual |
Queries to the server for information about the game.
p | The received packet. |
client_addr | The origin of the packet. |
Reimplemented from NetworkUDPSocketHandler.
Definition at line 165 of file network_udp.cpp.
References _network_game_info, _network_udp_server, _settings_client, _settings_game, NetworkGameInfo::clients_max, NetworkServerGameInfo::clients_on, NetworkGameInfo::companies_on, ConvertYMDToDate(), GameSettings::game_creation, NetworkSettings::max_clients, ClientSettings::network, NetworkGameInfo::server_lang, NetworkSettings::server_lang, NetworkSettings::server_password, NetworkGameInfo::start_date, GameCreationSettings::starting_year, StrEmpty(), and NetworkGameInfo::use_password.
|
protectedvirtual |
A client has requested the names of some NewGRFs.
Replying this can be tricky as we have a limit of SEND_MTU bytes in the reply packet and we can send up to 100 bytes per NewGRF (GRF ID, MD5sum and NETWORK_GRF_NAME_LENGTH bytes for the name). As SEND_MTU is much less than 100 * NETWORK_MAX_GRF_COUNT, it could be that a packet overflows. To stop this we only reply with the first N NewGRFs so that if the first N + 1 NewGRFs would be sent, the packet overflows. in_reply and in_reply_count are used to keep a list of GRFs to send in the reply.
Reimplemented from NetworkUDPSocketHandler.
Definition at line 272 of file network_udp.cpp.
References DEBUG, FGCM_EXACT, FindGRFConfig(), NetworkAddress::GetAddressAsString(), GRFConfig::GetName(), GRFIdentifier::grfid, lastof, GRFIdentifier::md5sum, min(), NETWORK_GRF_NAME_LENGTH, NETWORK_MAX_GRF_COUNT, PACKET_UDP_SERVER_NEWGRFS, Packet::Recv_uint8(), SEND_MTU, Packet::Send_string(), Packet::Send_uint8(), and strecpy().