OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #ifndef NETWORK_SERVER_H
11 #define NETWORK_SERVER_H
82 void CheckNextClientToSendMap(NetworkClientSocket *ignore_cs =
nullptr);
NetworkRecvStatus Receive_CLIENT_QUIT(Packet *p) override
The client is quitting the game.
NetworkRecvStatus SendGameInfo()
Send the client information about the server.
NetworkRecvStatus SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64 data)
Send a chat message.
@ STATUS_PRE_ACTIVE
The client is catching up the delayed frames.
NetworkAction
Actions that can be used for NetworkTextMessage.
NetworkRecvStatus Receive_CLIENT_SET_PASSWORD(Packet *p) override
Set the password for the clients current company: string The password.
size_t receive_limit
Amount of bytes that we can receive at this moment.
uint32 last_token_frame
The last frame we received the right token.
static const char * GetName()
Get the name used by the listener.
virtual Packet * ReceivePacket() override
Receives a packet for the given client.
@ STATUS_MAP
The client is downloading the map.
@ STATUS_MAP_WAIT
The client is waiting as someone else is downloading the map.
Owner
Enum for all companies/owners.
Base socket handler for all TCP sockets.
NetworkRecvStatus Receive_CLIENT_MAP_OK(Packet *p) override
Tell the server that we are done receiving/loading the map.
@ STATUS_ACTIVE
The client is active within in the game.
NetworkRecvStatus SendCommand(const CommandPacket *cp)
Send a command to the client to execute.
NetworkRecvStatus Receive_CLIENT_COMPANY_PASSWORD(Packet *p) override
Send a password to the server to authorize uint8 Password type (see NetworkPasswordType).
NetworkRecvStatus Receive_CLIENT_NEWGRFS_CHECKED(Packet *p) override
Tell the server that we have the required GRFs.
std::string GetClientName() const
Get the name of the client, if the user did not send it yet, Client ID is used.
Template for TCP listeners.
~ServerNetworkGameSocketHandler()
Clear everything related to this client.
ClientStatus
Status of a client.
@ STATUS_INACTIVE
The client is not connected nor active.
static void Send()
Send the packets for the server sockets.
Writing a savegame directly to a number of packets.
Everything we need to know about a command to be able to execute it.
NetworkRecvStatus SendSync()
Request the client to sync.
NetworkRecvStatus SendConfigUpdate()
Send an update about the max company/spectator counts.
NetworkRecvStatus Receive_CLIENT_GAME_INFO(Packet *p) override
Request game information.
ClientID
'Unique' identifier to be given to clients
NetworkRecvStatus SendMove(ClientID client_id, CompanyID company_id)
Tell that a client moved to another company.
NetworkRecvStatus Receive_CLIENT_JOIN(Packet *p) override
Try to join the server: string OpenTTD revision (norev000 if no revision).
NetworkRecvStatus SendJoin(ClientID client_id)
Tell that a client joined.
NetworkRecvStatus SendFrame()
Tell the client that they may run to a particular frame.
NetworkRecvStatus SendRConResult(uint16 colour, const std::string &command)
Send the result of a console action.
void NetworkServerUpdateCompanyPassworded(CompanyID company_id, bool passworded)
Tell that a particular company is (not) passworded.
A queue of CommandPackets.
NetworkRecvStatus SendCompanyUpdate()
Send an update about the company password states.
NetworkRecvStatus SendWelcome()
Send the client a welcome message with some basic information.
NetworkRecvStatus Receive_CLIENT_MOVE(Packet *p) override
Request the server to move this client into another company: uint8 ID of the company the client wants...
static ServerNetworkGameSocketHandler * GetByClientID(ClientID client_id)
Return the client state given it's client-identifier.
NetworkRecvStatus SendError(NetworkErrorCode error, const std::string &reason={})
Send an error to the client, and close its connection.
ClientStatus status
Status of this client.
struct PacketWriter * savegame
Writer used to write the savegame.
Internal entity of a packet.
NetworkRecvStatus SendClientInfo(NetworkClientInfo *ci)
Send the client information about a client.
static void AcceptConnection(SOCKET s, const NetworkAddress &address)
Handle the accepting of a connection to the server.
@ STATUS_DONE_MAP
The client has downloaded the map.
NetworkRecvStatus SendQuit(ClientID client_id)
Tell the client another client quit.
byte lag_test
Byte used for lag-testing the client.
NetworkRecvStatus SendErrorQuit(ClientID client_id, NetworkErrorCode errorno)
Tell the client another client quit with an error.
Class for handling the server side of the game connection.
void NetworkServer_Tick(bool send_frame)
This is called every tick if this is a _network_server.
NetworkRecvStatus Receive_CLIENT_COMMAND(Packet *p) override
The client has done a command and wants us to handle it.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
const std::string & GetClientIP()
Get the IP address/hostname of the connected client.
Base class for all pools.
NetworkRecvStatus Receive_CLIENT_SET_NAME(Packet *p) override
Gives the client a new name: string New name of the client.
NetworkRecvStatus SendNewGame()
Tell the client we're starting a new game.
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
@ STATUS_NEWGRFS_CHECK
The client is checking NewGRFs.
static bool AllowConnection()
Whether an connection is allowed or not at this moment.
NetworkRecvStatus Receive_CLIENT_GETMAP(Packet *p) override
Request the map from the server.
NetworkRecvStatus SendMap()
This sends the map to the client.
NetworkRecvStatus SendNewGRFCheck()
Send the check for the NewGRFs.
@ STATUS_AUTH_COMPANY
The client is authorizing with company password.
NetworkRecvStatus SendNeedGamePassword()
Request the game password.
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
ClientID client_id
Client identifier.
NetworkRecvStatus Receive_CLIENT_ACK(Packet *p) override
Tell the server we are done with this frame: uint32 Current frame counter of the client.
Pool< NetworkClientSocket, ClientIndex, 8, MAX_CLIENT_SLOTS, PT_NCLIENT > NetworkClientSocketPool
Pool with all client sockets.
@ STATUS_END
Must ALWAYS be on the end of this list!! (period).
ServerNetworkGameSocketHandler(SOCKET s)
Create a new socket for the server side of the game connection.
NetworkRecvStatus Receive_CLIENT_RCON(Packet *p) override
Send an RCon command to the server: string RCon password.
NetworkAddress client_address
IP-address of the client (so they can be banned)
ServerNetworkGameSocketHandler NetworkClientSocket
Make the code look slightly nicer/simpler.
NetworkRecvStatus Receive_CLIENT_CHAT(Packet *p) override
Sends a chat-packet to the server: uint8 ID of the action (see NetworkAction).
NetworkRecvStatus Receive_CLIENT_GAME_PASSWORD(Packet *p) override
Send a password to the server to authorize: uint8 Password type (see NetworkPasswordType).
NetworkRecvStatus SendShutdown()
Tell the client we're shutting down.
byte last_token
The last random token we did send to verify the client is listening.
CommandQueue outgoing_queue
The command-queue awaiting delivery.
NetworkRecvStatus SendNeedCompanyPassword()
Request the company password.
Base class for all PoolItems.
NetworkClientSocketPool _networkclientsocket_pool
Make very sure the preconditions given in network_type.h are actually followed.
NetworkErrorCode
The error codes we send around in the protocols.
Container for all information known about a client.
void NetworkServerSetCompanyPassword(CompanyID company_id, const std::string &password, bool already_hashed=true)
Set/Reset a company password on the server end.
NetworkRecvStatus CloseConnection(NetworkRecvStatus status) override
Close the network connection due to the given status.
@ STATUS_AUTH_GAME
The client is authorizing with game (server) password.
NetworkRecvStatus SendWait()
Tell the client that its put in a waiting queue.
@ STATUS_AUTHORIZED
The client is authorized.
NetworkRecvStatus Receive_CLIENT_ERROR(Packet *p) override
The client made an error and is quitting the game.