Class for handling the server side of the game connection. More...
#include <network_server.h>
Public Types | |
| enum | ClientStatus { STATUS_INACTIVE, STATUS_NEWGRFS_CHECK, STATUS_AUTH_GAME, STATUS_AUTH_COMPANY, STATUS_AUTHORIZED, STATUS_MAP_WAIT, STATUS_MAP, STATUS_DONE_MAP, STATUS_PRE_ACTIVE, STATUS_ACTIVE, STATUS_END } |
Status of a client. More... | |
Public Member Functions | |
| ServerNetworkGameSocketHandler (SOCKET s) | |
| Create a new socket for the server side of the game connection. | |
| ~ServerNetworkGameSocketHandler () | |
| Clear everything related to this client. | |
| virtual Packet * | ReceivePacket () |
| virtual void | SendPacket (Packet *packet) |
| NetworkRecvStatus | CloseConnection (NetworkRecvStatus status) |
| void | GetClientName (char *client_name, size_t size) const |
| Get the name of the client, if the user did not send it yet, Client #<no> is used. | |
| NetworkRecvStatus | SendMap () |
| NetworkRecvStatus | SendErrorQuit (ClientID client_id, NetworkErrorCode errorno) |
| NetworkRecvStatus | SendQuit (ClientID client_id) |
| NetworkRecvStatus | SendShutdown () |
| NetworkRecvStatus | SendNewGame () |
| NetworkRecvStatus | SendRConResult (uint16 colour, const char *command) |
| NetworkRecvStatus | SendMove (ClientID client_id, CompanyID company_id) |
| NetworkRecvStatus | SendClientInfo (NetworkClientInfo *ci) |
| NetworkRecvStatus | SendError (NetworkErrorCode error) |
| NetworkRecvStatus | SendChat (NetworkAction action, ClientID client_id, bool self_send, const char *msg, int64 data) |
| NetworkRecvStatus | SendJoin (ClientID client_id) |
| NetworkRecvStatus | SendFrame () |
| NetworkRecvStatus | SendSync () |
| NetworkRecvStatus | SendCommand (const CommandPacket *cp) |
| NetworkRecvStatus | SendCompanyUpdate () |
| NetworkRecvStatus | SendConfigUpdate () |
| const char * | GetClientIP () |
| Get the IP address/hostname of the connected client. | |
Static Public Member Functions | |
| static void | Send () |
| Send the packets for the server sockets. | |
| static void | AcceptConnection (SOCKET s, const NetworkAddress &address) |
| static bool | AllowConnection () |
| Whether an connection is allowed or not at this moment. | |
| static const char * | GetName () |
| Get the name used by the listener. | |
|
static ServerNetworkGameSocketHandler * | GetByClientID (ClientID client_id) |
Data Fields | |
| byte | lag_test |
| Byte used for lag-testing the client. | |
| byte | last_token |
| The last random token we did send to verify the client is listening. | |
| uint32 | last_token_frame |
| The last frame we received the right token. | |
| ClientStatus | status |
| Status of this client. | |
| CommandQueue | outgoing_queue |
| The command-queue awaiting delivery. | |
| int | receive_limit |
| Amount of bytes that we can receive at this moment. | |
| Packet * | savegame_packets |
| Packet queue of the savegame; send these "slowly" to the client. | |
| struct PacketWriter * | savegame |
| Writer used to write the savegame. | |
| ThreadMutex * | savegame_mutex |
| Mutex for making threaded saving safe. | |
| NetworkAddress | client_address |
| IP-address of the client (so he can be banned). | |
Protected Member Functions | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_JOIN) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_COMPANY_INFO) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_GAME_PASSWORD) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_COMPANY_PASSWORD) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_GETMAP) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_MAP_OK) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_ACK) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_COMMAND) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_CHAT) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_SET_PASSWORD) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_SET_NAME) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_QUIT) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_ERROR) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_RCON) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_NEWGRFS_CHECKED) | |
| DECLARE_GAME_RECEIVE_COMMAND (PACKET_CLIENT_MOVE) | |
| NetworkRecvStatus | SendCompanyInfo () |
| NetworkRecvStatus | SendNewGRFCheck () |
| NetworkRecvStatus | SendWelcome () |
| NetworkRecvStatus | SendWait () |
| NetworkRecvStatus | SendNeedGamePassword () |
| NetworkRecvStatus | SendNeedCompanyPassword () |
Class for handling the server side of the game connection.
Definition at line 27 of file network_server.h.
Status of a client.
Definition at line 55 of file network_server.h.
| ServerNetworkGameSocketHandler::ServerNetworkGameSocketHandler | ( | SOCKET | s | ) |
Create a new socket for the server side of the game connection.
| s | The socket to connect with. |
Definition at line 154 of file network_server.cpp.
References _network_client_id, _settings_client, NetworkSettings::bytes_per_frame_burst, NetworkGameSocketHandler::client_id, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::MAX_SIZE, ClientSettings::network, receive_limit, and status.
| bool ServerNetworkGameSocketHandler::AllowConnection | ( | ) | [static] |
Whether an connection is allowed or not at this moment.
Definition at line 266 of file network_server.cpp.
References _settings_client, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_networkclientsocket_pool >::CanAllocateItem(), NetworkServerGameInfo::clients_on, NetworkSettings::max_clients, MAX_CLIENTS, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::MAX_SIZE, and ClientSettings::network.
| const char * ServerNetworkGameSocketHandler::GetClientIP | ( | ) |
Get the IP address/hostname of the connected client.
Definition at line 1813 of file network_server.cpp.
References client_address, and NetworkAddress::GetHostname().
| void ServerNetworkGameSocketHandler::GetClientName | ( | char * | client_name, | |
| size_t | size | |||
| ) | const |
Get the name of the client, if the user did not send it yet, Client #<no> is used.
| client_name | The variable to write the name to. | |
| size | The amount of bytes we can write. |
Definition at line 1966 of file network_server.cpp.
References NetworkClientInfo::client_name, StrEmpty(), and ttd_strlcpy().
| static const char* ServerNetworkGameSocketHandler::GetName | ( | ) | [inline, static] |
Get the name used by the listener.
Definition at line 115 of file network_server.h.
| void ServerNetworkGameSocketHandler::Send | ( | ) | [static] |
Send the packets for the server sockets.
Definition at line 279 of file network_server.cpp.
References SPS_CLOSED.
1.7.1