ServerNetworkUDPSocketHandler Class Reference

*** Communication with clients (we are server) ***/ More...

Inheritance diagram for ServerNetworkUDPSocketHandler:
NetworkUDPSocketHandler NetworkSocketHandler

Public Member Functions

 ServerNetworkUDPSocketHandler (NetworkAddressList *addresses)
 Create the socket.

Protected Member Functions

virtual void Receive_CLIENT_FIND_SERVER (Packet *p, NetworkAddress *client_addr)
 Queries to the server for information about the game.
virtual void Receive_CLIENT_DETAIL_INFO (Packet *p, NetworkAddress *client_addr)
 Query for detailed information about companies.
virtual void Receive_CLIENT_GET_NEWGRFS (Packet *p, NetworkAddress *client_addr)
 A client has requested the names of some NewGRFs.

Detailed Description

*** Communication with clients (we are server) ***/

Helper class for handling all server side communication.

Definition at line 85 of file network_udp.cpp.


Constructor & Destructor Documentation

ServerNetworkUDPSocketHandler::ServerNetworkUDPSocketHandler ( NetworkAddressList addresses  )  [inline]

Create the socket.

Parameters:
addresses The addresses to bind on.

Definition at line 95 of file network_udp.cpp.


Member Function Documentation

void ServerNetworkUDPSocketHandler::Receive_CLIENT_DETAIL_INFO ( Packet p,
NetworkAddress client_addr 
) [protected, virtual]
void ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER ( Packet p,
NetworkAddress client_addr 
) [protected, virtual]

Queries to the server for information about the game.

Parameters:
p The received packet.
client_addr The origin of the packet.

Reimplemented from NetworkUDPSocketHandler.

Definition at line 99 of file network_udp.cpp.

References _date, _grfconfig, _network_dedicated, _network_game_info, _network_udp_server, _settings_client, _settings_game, NetworkGameInfo::clients_max, NetworkServerGameInfo::clients_on, NetworkGameInfo::companies_max, NetworkGameInfo::companies_on, ConvertYMDToDate(), DEBUG, NetworkGameInfo::dedicated, GameSettings::game_creation, NetworkGameInfo::game_date, NetworkAddress::GetHostname(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetNumItems(), NetworkGameInfo::grfconfig, GameCreationSettings::landscape, lastof, NetworkGameInfo::map_height, NetworkServerGameInfo::map_name, NetworkGameInfo::map_set, NetworkGameInfo::map_width, MapSizeX(), MapSizeY(), NetworkSettings::max_clients, NetworkSettings::max_companies, NetworkSettings::max_spectators, ClientSettings::network, PACKET_UDP_SERVER_RESPONSE, NetworkUDPSocketHandler::SendNetworkGameInfo(), NetworkUDPSocketHandler::SendPacket(), NetworkSettings::server_lang, NetworkGameInfo::server_lang, NetworkSettings::server_name, NetworkGameInfo::server_name, NetworkSettings::server_password, NetworkGameInfo::server_revision, NetworkGameInfo::spectators_max, NetworkGameInfo::spectators_on, NetworkGameInfo::start_date, GameCreationSettings::starting_year, strecpy(), StrEmpty(), and NetworkGameInfo::use_password.

void ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS ( Packet p,
NetworkAddress client_addr 
) [protected, virtual]

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 206 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, NetworkSocketHandler::ReceiveGRFIdentifier(), Packet::Recv_uint8(), SEND_MTU, Packet::Send_string(), Packet::Send_uint8(), NetworkSocketHandler::SendGRFIdentifier(), NetworkUDPSocketHandler::SendPacket(), and strecpy().


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

Generated on Fri May 27 04:21:13 2011 for OpenTTD by  doxygen 1.6.1