OpenTTD Source
12.0-beta2
|
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... | |
![]() | |
typedef struct Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero > | Pool |
Type of the pool this item is going to be part of. | |
Public Member Functions | |
ServerNetworkGameSocketHandler (SOCKET s) | |
Create a new socket for the server side of the game connection. More... | |
~ServerNetworkGameSocketHandler () | |
Clear everything related to this client. | |
virtual Packet * | ReceivePacket () override |
Receives a packet for the given client. More... | |
NetworkRecvStatus | CloseConnection (NetworkRecvStatus status) override |
Close the network connection due to the given status. More... | |
std::string | GetClientName () const |
Get the name of the client, if the user did not send it yet, Client ID is used. More... | |
void | CheckNextClientToSendMap (NetworkClientSocket *ignore_cs=nullptr) |
NetworkRecvStatus | SendWait () |
Tell the client that its put in a waiting queue. | |
NetworkRecvStatus | SendMap () |
This sends the map to the client. | |
NetworkRecvStatus | SendErrorQuit (ClientID client_id, NetworkErrorCode errorno) |
Tell the client another client quit with an error. More... | |
NetworkRecvStatus | SendQuit (ClientID client_id) |
Tell the client another client quit. More... | |
NetworkRecvStatus | SendShutdown () |
Tell the client we're shutting down. | |
NetworkRecvStatus | SendNewGame () |
Tell the client we're starting a new game. | |
NetworkRecvStatus | SendRConResult (uint16 colour, const std::string &command) |
Send the result of a console action. More... | |
NetworkRecvStatus | SendMove (ClientID client_id, CompanyID company_id) |
Tell that a client moved to another company. More... | |
NetworkRecvStatus | SendClientInfo (NetworkClientInfo *ci) |
Send the client information about a client. More... | |
NetworkRecvStatus | SendError (NetworkErrorCode error, const std::string &reason={}) |
Send an error to the client, and close its connection. More... | |
NetworkRecvStatus | SendChat (NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64 data) |
Send a chat message. More... | |
NetworkRecvStatus | SendJoin (ClientID client_id) |
Tell that a client joined. More... | |
NetworkRecvStatus | SendFrame () |
Tell the client that they may run to a particular frame. | |
NetworkRecvStatus | SendSync () |
Request the client to sync. | |
NetworkRecvStatus | SendCommand (const CommandPacket *cp) |
Send a command to the client to execute. More... | |
NetworkRecvStatus | SendCompanyUpdate () |
Send an update about the company password states. | |
NetworkRecvStatus | SendConfigUpdate () |
Send an update about the max company/spectator counts. | |
const std::string & | GetClientIP () |
Get the IP address/hostname of the connected client. More... | |
![]() | |
void * | operator new (size_t size) |
Allocates space for new Titem. More... | |
void * | operator new (size_t size, size_t index) |
Allocates space for new Titem with given index. More... | |
void * | operator new (size_t size, void *ptr) |
Allocates space for new Titem at given memory address. More... | |
void | operator delete (void *p) |
Marks Titem as free. More... | |
![]() | |
NetworkRecvStatus | CloseConnection (bool error=true) override |
Functions to help ReceivePacket/SendPacket a bit A socket can make errors. More... | |
void | SetInfo (NetworkClientInfo *info) |
Sets the client info for this socket handler. More... | |
NetworkClientInfo * | GetInfo () const |
Gets the client info of this socket handler. More... | |
NetworkRecvStatus | ReceivePackets () |
Do the actual receiving of packets. More... | |
const char * | ReceiveCommand (Packet *p, CommandPacket *cp) |
Receives a command from the network. More... | |
void | SendCommand (Packet *p, const CommandPacket *cp) |
Sends a command over the network. More... | |
![]() | |
bool | IsConnected () const |
Whether this socket is currently bound to a socket. More... | |
void | CloseSocket () |
Close the actual socket of the connection. More... | |
virtual void | SendPacket (Packet *packet) |
This function puts the packet in the send-queue and it is send as soon as possible. More... | |
SendPacketsState | SendPackets (bool closing_down=false) |
Sends all the buffered packets out for this client. More... | |
bool | CanSendReceive () |
Check whether this socket can send or receive something. More... | |
bool | HasSendQueue () |
Whether there is something pending in the send queue. More... | |
NetworkTCPSocketHandler (SOCKET s=INVALID_SOCKET) | |
Construct a socket handler for a TCP connection. More... | |
![]() | |
NetworkSocketHandler () | |
Create a new unbound socket. | |
virtual | ~NetworkSocketHandler () |
Close the socket when destructing the socket handler. | |
void | MarkClosed () |
Mark the connection as closed. More... | |
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. | |
Static Public Member Functions | |
static void | Send () |
Send the packets for the server sockets. | |
static void | AcceptConnection (SOCKET s, const NetworkAddress &address) |
Handle the accepting of a connection to the server. More... | |
static bool | AllowConnection () |
Whether an connection is allowed or not at this moment. More... | |
static const char * | GetName () |
Get the name used by the listener. More... | |
static ServerNetworkGameSocketHandler * | GetByClientID (ClientID client_id) |
Return the client state given it's client-identifier. More... | |
![]() | |
static bool | CanAllocateItem (size_t n=1) |
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() More... | |
static bool | CleaningPool () |
Returns current state of pool cleaning - yes or no. More... | |
static bool | IsValidID (size_t index) |
Tests whether given index can be used to get valid (non-nullptr) Titem. More... | |
static Titem * | Get (size_t index) |
Returns Titem with given index. More... | |
static Titem * | GetIfValid (size_t index) |
Returns Titem with given index. More... | |
static size_t | GetPoolSize () |
Returns first unused index. More... | |
static size_t | GetNumItems () |
Returns number of valid items in the pool. More... | |
static void | PostDestructor (size_t index) |
Dummy function called after destructor of each member. More... | |
static Pool::IterateWrapper< Titem > | Iterate (size_t from=0) |
Returns an iterable ensemble of all valid Titem. More... | |
![]() | |
static bool | ValidateClient (SOCKET s, NetworkAddress &address) |
static void | AcceptClient (SOCKET ls) |
Accepts clients from the sockets. More... | |
static bool | Receive () |
Handle the receiving of packets. More... | |
static bool | Listen (uint16 port) |
Listen on a particular port. More... | |
static void | CloseListeners () |
Close the sockets we're listening on. | |
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. | |
size_t | receive_limit |
Amount of bytes that we can receive at this moment. | |
struct PacketWriter * | savegame |
Writer used to write the savegame. | |
NetworkAddress | client_address |
IP-address of the client (so they can be banned) | |
![]() | |
Tindex | index |
Index of this pool item. | |
![]() | |
ClientID | client_id |
Client identifier. | |
uint32 | last_frame |
Last frame we have executed. | |
uint32 | last_frame_server |
Last frame the server has executed. | |
CommandQueue | incoming_queue |
The command-queue awaiting handling. | |
std::chrono::steady_clock::time_point | last_packet |
Time we received the last frame. | |
![]() | |
SOCKET | sock |
The socket currently connected to. | |
bool | writable |
Can we write to this socket? | |
Protected Member Functions | |
NetworkRecvStatus | Receive_CLIENT_JOIN (Packet *p) override |
Try to join the server: string OpenTTD revision (norev000 if no revision). More... | |
NetworkRecvStatus | Receive_CLIENT_GAME_INFO (Packet *p) override |
Request game information. More... | |
NetworkRecvStatus | Receive_CLIENT_GAME_PASSWORD (Packet *p) override |
Send a password to the server to authorize: uint8 Password type (see NetworkPasswordType). More... | |
NetworkRecvStatus | Receive_CLIENT_COMPANY_PASSWORD (Packet *p) override |
Send a password to the server to authorize uint8 Password type (see NetworkPasswordType). More... | |
NetworkRecvStatus | Receive_CLIENT_GETMAP (Packet *p) override |
Request the map from the server. More... | |
NetworkRecvStatus | Receive_CLIENT_MAP_OK (Packet *p) override |
Tell the server that we are done receiving/loading the map. More... | |
NetworkRecvStatus | Receive_CLIENT_ACK (Packet *p) override |
Tell the server we are done with this frame: uint32 Current frame counter of the client. More... | |
NetworkRecvStatus | Receive_CLIENT_COMMAND (Packet *p) override |
The client has done a command and wants us to handle it. More... | |
NetworkRecvStatus | Receive_CLIENT_CHAT (Packet *p) override |
Sends a chat-packet to the server: uint8 ID of the action (see NetworkAction). More... | |
NetworkRecvStatus | Receive_CLIENT_SET_PASSWORD (Packet *p) override |
Set the password for the clients current company: string The password. More... | |
NetworkRecvStatus | Receive_CLIENT_SET_NAME (Packet *p) override |
Gives the client a new name: string New name of the client. More... | |
NetworkRecvStatus | Receive_CLIENT_QUIT (Packet *p) override |
The client is quitting the game. More... | |
NetworkRecvStatus | Receive_CLIENT_ERROR (Packet *p) override |
The client made an error and is quitting the game. More... | |
NetworkRecvStatus | Receive_CLIENT_RCON (Packet *p) override |
Send an RCon command to the server: string RCon password. More... | |
NetworkRecvStatus | Receive_CLIENT_NEWGRFS_CHECKED (Packet *p) override |
Tell the server that we have the required GRFs. More... | |
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 to join. More... | |
NetworkRecvStatus | SendGameInfo () |
Send the client information about the server. | |
NetworkRecvStatus | SendNewGRFCheck () |
Send the check for the NewGRFs. | |
NetworkRecvStatus | SendWelcome () |
Send the client a welcome message with some basic information. | |
NetworkRecvStatus | SendNeedGamePassword () |
Request the game password. | |
NetworkRecvStatus | SendNeedCompanyPassword () |
Request the company password. | |
![]() | |
NetworkRecvStatus | ReceiveInvalidPacket (PacketGameType type) |
Helper for logging receiving invalid packets. More... | |
virtual NetworkRecvStatus | Receive_SERVER_FULL (Packet *p) |
Notification that the server is full. More... | |
virtual NetworkRecvStatus | Receive_SERVER_BANNED (Packet *p) |
Notification that the client trying to join is banned. More... | |
virtual NetworkRecvStatus | Receive_SERVER_ERROR (Packet *p) |
The client made an error: uint8 Error code caused (see NetworkErrorCode). More... | |
virtual NetworkRecvStatus | Receive_SERVER_GAME_INFO (Packet *p) |
Sends information about the game. More... | |
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_INFO (Packet *p) |
Send information about a client: uint32 ID of the client (always unique on a server. More... | |
virtual NetworkRecvStatus | Receive_SERVER_NEED_GAME_PASSWORD (Packet *p) |
Indication to the client that the server needs a game password. More... | |
virtual NetworkRecvStatus | Receive_SERVER_NEED_COMPANY_PASSWORD (Packet *p) |
Indication to the client that the server needs a company password: uint32 Generation seed. More... | |
virtual NetworkRecvStatus | Receive_SERVER_WELCOME (Packet *p) |
The client is joined and ready to receive their map: uint32 Own client ID. More... | |
virtual NetworkRecvStatus | Receive_SERVER_WAIT (Packet *p) |
Notification that another client is currently receiving the map: uint8 Number of clients waiting in front of you. More... | |
virtual NetworkRecvStatus | Receive_SERVER_MAP_BEGIN (Packet *p) |
Sends that the server will begin with sending the map to the client: uint32 Current frame. More... | |
virtual NetworkRecvStatus | Receive_SERVER_MAP_SIZE (Packet *p) |
Sends the size of the map to the client. More... | |
virtual NetworkRecvStatus | Receive_SERVER_MAP_DATA (Packet *p) |
Sends the data of the map to the client: Contains a part of the map (until max size of packet). More... | |
virtual NetworkRecvStatus | Receive_SERVER_MAP_DONE (Packet *p) |
Sends that all data of the map are sent to the client: More... | |
virtual NetworkRecvStatus | Receive_SERVER_JOIN (Packet *p) |
A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO: uint32 ID of the client that just joined the game. More... | |
virtual NetworkRecvStatus | Receive_SERVER_FRAME (Packet *p) |
Sends the current frame counter to the client: uint32 Frame counter uint32 Frame counter max (how far may the client walk before the server?) uint32 General seed 1 (dependent on compile settings, not default). More... | |
virtual NetworkRecvStatus | Receive_SERVER_SYNC (Packet *p) |
Sends a sync-check to the client: uint32 Frame counter. More... | |
virtual NetworkRecvStatus | Receive_SERVER_COMMAND (Packet *p) |
Sends a DoCommand to the client: uint8 ID of the company (0..MAX_COMPANIES-1). More... | |
virtual NetworkRecvStatus | Receive_SERVER_CHAT (Packet *p) |
Sends a chat-packet to the client: uint8 ID of the action (see NetworkAction). More... | |
virtual NetworkRecvStatus | Receive_SERVER_QUIT (Packet *p) |
Notification that a client left the game: uint32 ID of the client. More... | |
virtual NetworkRecvStatus | Receive_SERVER_ERROR_QUIT (Packet *p) |
Inform all clients that one client made an error and thus has quit/been disconnected: uint32 ID of the client that caused the error. More... | |
virtual NetworkRecvStatus | Receive_SERVER_SHUTDOWN (Packet *p) |
Let the clients know that the server is closing. More... | |
virtual NetworkRecvStatus | Receive_SERVER_NEWGAME (Packet *p) |
Let the clients know that the server is loading a new map. More... | |
virtual NetworkRecvStatus | Receive_SERVER_RCON (Packet *p) |
Send the result of an issues RCon command back to the client: uint16 Colour code. More... | |
virtual NetworkRecvStatus | Receive_SERVER_CHECK_NEWGRFS (Packet *p) |
Sends information about all used GRFs to the client: uint8 Amount of GRFs (the following data is repeated this many times, i.e. More... | |
virtual NetworkRecvStatus | Receive_SERVER_MOVE (Packet *p) |
Move a client from one company into another: uint32 ID of the client. More... | |
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_UPDATE (Packet *p) |
Update the clients knowledge of which company is password protected: uint16 Bitwise representation of each company. More... | |
virtual NetworkRecvStatus | Receive_SERVER_CONFIG_UPDATE (Packet *p) |
Update the clients knowledge of the max settings: uint8 Maximum number of companies allowed. More... | |
NetworkRecvStatus | HandlePacket (Packet *p) |
Handle the given packet, i.e. More... | |
NetworkGameSocketHandler (SOCKET s) | |
Create a new socket for the game connection. More... | |
Class for handling the server side of the game connection.
Definition at line 24 of file network_server.h.
Status of a client.
Definition at line 51 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 208 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, Tpool_type, Tcache, Tzero >::MAX_SIZE, ClientSettings::network, receive_limit, status, and STATUS_INACTIVE.
Referenced by AcceptConnection().
|
static |
Handle the accepting of a connection to the server.
s | The socket of the new connection. |
address | The address of the peer. |
Definition at line 550 of file network.cpp.
References _network_clients_connected, client_address, InvalidateWindowData(), ServerNetworkGameSocketHandler(), and WC_CLIENT_LIST.
Referenced by ClientNetworkCoordinatorSocketHandler::ConnectSuccess().
|
static |
Whether an connection is allowed or not at this moment.
Definition at line 305 of file network_server.cpp.
References _network_clients_connected, _network_game_info, _settings_client, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_networkclientsocket_pool >::CanAllocateItem(), NetworkServerGameInfo::clients_on, MAX_CLIENTS, NetworkSettings::max_clients, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::MAX_SIZE, and ClientSettings::network.
|
overridevirtual |
Close the network connection due to the given status.
status | The reason the connection got closed. |
Implements NetworkGameSocketHandler.
Definition at line 247 of file network_server.cpp.
References GetClientName(), NetworkSocketHandler::HasClientQuit(), NETWORK_RECV_STATUS_CLIENT_QUIT, NETWORK_RECV_STATUS_OKAY, NETWORK_RECV_STATUS_SERVER_ERROR, NetworkTCPSocketHandler::sock, status, and STATUS_AUTHORIZED.
Referenced by Receive_CLIENT_ERROR(), Receive_CLIENT_QUIT(), SendNeedCompanyPassword(), SendNeedGamePassword(), and SendWelcome().
|
static |
Return the client state given it's client-identifier.
client_id | the ClientID to search for |
Definition at line 126 of file network.cpp.
References NetworkGameSocketHandler::client_id.
const std::string & ServerNetworkGameSocketHandler::GetClientIP | ( | ) |
Get the IP address/hostname of the connected client.
Definition at line 1791 of file network_server.cpp.
References client_address, and NetworkAddress::GetHostname().
std::string ServerNetworkGameSocketHandler::GetClientName | ( | ) | const |
Get the name of the client, if the user did not send it yet, Client ID is used.
client_name | The variable to write the name to. |
last | The pointer to the last element of the destination buffer |
Definition at line 1989 of file network_server.cpp.
References NetworkGameSocketHandler::client_id, NetworkClientInfo::client_name, and NetworkGameSocketHandler::GetInfo().
Referenced by CloseConnection(), Receive_CLIENT_ERROR(), Receive_CLIENT_MAP_OK(), Receive_CLIENT_QUIT(), and SendError().
|
inlinestatic |
Get the name used by the listener.
Definition at line 111 of file network_server.h.
Referenced by ClientNetworkCoordinatorSocketHandler::ConnectSuccess().
|
overrideprotectedvirtual |
Tell the server we are done with this frame: uint32 Current frame counter of the client.
uint8 The random token that the server sent in the PACKET_SERVER_FRAME packet.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1097 of file network_server.cpp.
References SendError(), status, and STATUS_AUTHORIZED.
|
overrideprotectedvirtual |
Sends a chat-packet to the server: uint8 ID of the action (see NetworkAction).
uint8 ID of the destination type (see DestType). uint32 ID of the client or company (destination of the chat). string Message (max NETWORK_CHAT_LENGTH). uint64 data (used e.g. for 'give money' actions).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1264 of file network_server.cpp.
References SendError(), status, and STATUS_PRE_ACTIVE.
|
overrideprotectedvirtual |
The client has done a command and wants us to handle it.
p | the packet in which the command was sent |
Only CMD_COMPANY_CTRL is always allowed, for the rest, playas needs to match the company in the packet. If it doesn't, the client has done something pretty naughty (or a bug), and will be kicked
Reimplemented from NetworkGameSocketHandler.
Definition at line 982 of file network_server.cpp.
References NetworkSocketHandler::HasClientQuit(), and SendError().
|
overrideprotectedvirtual |
Send a password to the server to authorize uint8 Password type (see NetworkPasswordType).
string The password.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 895 of file network_server.cpp.
References SendError(), status, and STATUS_AUTH_COMPANY.
|
overrideprotectedvirtual |
The client made an error and is quitting the game.
uint8 Error of the code caused (see NetworkErrorCode).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1046 of file network_server.cpp.
References CloseConnection(), Debug, GetClientName(), GetNetworkErrorMsg(), NetworkSocketHandler::HasClientQuit(), NETWORK_RECV_STATUS_CLIENT_QUIT, and Packet::Recv_uint8().
|
overrideprotectedvirtual |
Request game information.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 775 of file network_server.cpp.
References SendGameInfo().
|
overrideprotectedvirtual |
Send a password to the server to authorize: uint8 Password type (see NetworkPasswordType).
string The password.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 871 of file network_server.cpp.
References SendError(), status, and STATUS_AUTH_GAME.
|
overrideprotectedvirtual |
Request the map from the server.
uint32 NewGRF version (release versions of OpenTTD only).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 916 of file network_server.cpp.
References NetworkSocketHandler::HasClientQuit(), and SendError().
|
overrideprotectedvirtual |
Try to join the server: string OpenTTD revision (norev000 if no revision).
string Name of the client (max NETWORK_NAME_LENGTH). uint8 ID of the company to play as (1..MAX_COMPANIES). uint8 ID of the clients Language.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 801 of file network_server.cpp.
References SendError(), status, and STATUS_INACTIVE.
|
overrideprotectedvirtual |
Tell the server that we are done receiving/loading the map.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 937 of file network_server.cpp.
References GetClientName(), NetworkSocketHandler::HasClientQuit(), status, and STATUS_DONE_MAP.
|
overrideprotectedvirtual |
Request the server to move this client into another company: uint8 ID of the company the client wants to join.
string Password, if the company is password protected.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1360 of file network_server.cpp.
References SendError(), status, and STATUS_ACTIVE.
|
overrideprotectedvirtual |
Tell the server that we have the required GRFs.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 780 of file network_server.cpp.
References SendError(), status, and STATUS_NEWGRFS_CHECK.
|
overrideprotectedvirtual |
The client is quitting the game.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1075 of file network_server.cpp.
References CloseConnection(), GetClientName(), NetworkSocketHandler::HasClientQuit(), and NETWORK_RECV_STATUS_CLIENT_QUIT.
|
overrideprotectedvirtual |
Send an RCon command to the server: string RCon password.
string Command to be executed.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1338 of file network_server.cpp.
References SendError(), status, and STATUS_ACTIVE.
|
overrideprotectedvirtual |
Gives the client a new name: string New name of the client.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1306 of file network_server.cpp.
References SendError(), status, and STATUS_ACTIVE.
|
overrideprotectedvirtual |
Set the password for the clients current company: string The password.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1292 of file network_server.cpp.
References SendError(), status, and STATUS_ACTIVE.
|
overridevirtual |
Receives a packet for the given client.
Reimplemented from NetworkTCPSocketHandler.
Definition at line 234 of file network_server.cpp.
References receive_limit, NetworkTCPSocketHandler::ReceivePacket(), and Packet::Size().
NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat | ( | NetworkAction | action, |
ClientID | client_id, | ||
bool | self_send, | ||
const std::string & | msg, | ||
int64 | data | ||
) |
Send a chat message.
action | The action associated with the message. |
client_id | The origin of the chat message. |
self_send | Whether we did send the message. |
msg | The actual message. |
data | Arbitrary extra data. |
Definition at line 657 of file network_server.cpp.
References NetworkGameSocketHandler::client_id, NETWORK_RECV_STATUS_OKAY, PACKET_SERVER_CHAT, Packet::Send_bool(), Packet::Send_string(), Packet::Send_uint32(), Packet::Send_uint64(), Packet::Send_uint8(), NetworkTCPSocketHandler::SendPacket(), status, and STATUS_PRE_ACTIVE.
NetworkRecvStatus ServerNetworkGameSocketHandler::SendClientInfo | ( | NetworkClientInfo * | ci | ) |
Send the client information about a client.
ci | The client to send information about. |
Definition at line 341 of file network_server.cpp.
References NetworkClientInfo::client_id, NetworkClientInfo::client_name, NetworkClientInfo::client_playas, INVALID_CLIENT_ID, NETWORK_RECV_STATUS_OKAY, PACKET_SERVER_CLIENT_INFO, Packet::Send_string(), Packet::Send_uint32(), Packet::Send_uint8(), and NetworkTCPSocketHandler::SendPacket().
Referenced by SendWelcome().
NetworkRecvStatus ServerNetworkGameSocketHandler::SendCommand | ( | const CommandPacket * | cp | ) |
Send a command to the client to execute.
cp | The command to send. |
Definition at line 637 of file network_server.cpp.
References CommandPacket::frame, CommandPacket::my_cmd, NETWORK_RECV_STATUS_OKAY, PACKET_SERVER_COMMAND, Packet::Send_bool(), Packet::Send_uint32(), NetworkGameSocketHandler::SendCommand(), and NetworkTCPSocketHandler::SendPacket().
NetworkRecvStatus ServerNetworkGameSocketHandler::SendError | ( | NetworkErrorCode | error, |
const std::string & | reason = {} |
||
) |
Send an error to the client, and close its connection.
error | The error to disconnect for. |
reason | In case of kicking a client, specifies the reason for kicking the client. |
Definition at line 370 of file network_server.cpp.
References Debug, error(), GetClientName(), GetNetworkErrorMsg(), PACKET_SERVER_ERROR, Packet::Send_string(), Packet::Send_uint8(), NetworkTCPSocketHandler::SendPacket(), status, and STATUS_AUTHORIZED.
Referenced by Receive_CLIENT_ACK(), Receive_CLIENT_CHAT(), Receive_CLIENT_COMMAND(), Receive_CLIENT_COMPANY_PASSWORD(), Receive_CLIENT_GAME_PASSWORD(), Receive_CLIENT_GETMAP(), Receive_CLIENT_JOIN(), Receive_CLIENT_MOVE(), Receive_CLIENT_NEWGRFS_CHECKED(), Receive_CLIENT_RCON(), Receive_CLIENT_SET_NAME(), Receive_CLIENT_SET_PASSWORD(), and SendMap().
NetworkRecvStatus ServerNetworkGameSocketHandler::SendErrorQuit | ( | ClientID | client_id, |
NetworkErrorCode | errorno | ||
) |
Tell the client another client quit with an error.
client_id | The client that quit. |
errorno | The reason the client quit. |
Definition at line 678 of file network_server.cpp.
References NetworkGameSocketHandler::client_id, NETWORK_RECV_STATUS_OKAY, PACKET_SERVER_ERROR_QUIT, Packet::Send_uint32(), Packet::Send_uint8(), and NetworkTCPSocketHandler::SendPacket().
NetworkRecvStatus ServerNetworkGameSocketHandler::SendJoin | ( | ClientID | client_id | ) |
Tell that a client joined.
client_id | The client that joined. |
Definition at line 586 of file network_server.cpp.
References NetworkGameSocketHandler::client_id, NETWORK_RECV_STATUS_OKAY, PACKET_SERVER_JOIN, Packet::Send_uint32(), and NetworkTCPSocketHandler::SendPacket().
NetworkRecvStatus ServerNetworkGameSocketHandler::SendMove | ( | ClientID | client_id, |
CompanyID | company_id | ||
) |
Tell that a client moved to another company.
client_id | The client that moved. |
company_id | The company the client moved to. |
Definition at line 739 of file network_server.cpp.
References NetworkGameSocketHandler::client_id, NETWORK_RECV_STATUS_OKAY, PACKET_SERVER_MOVE, Packet::Send_uint32(), Packet::Send_uint8(), and NetworkTCPSocketHandler::SendPacket().
NetworkRecvStatus ServerNetworkGameSocketHandler::SendQuit | ( | ClientID | client_id | ) |
Tell the client another client quit.
client_id | The client that quit. |
Definition at line 693 of file network_server.cpp.
References NetworkGameSocketHandler::client_id, NETWORK_RECV_STATUS_OKAY, PACKET_SERVER_QUIT, Packet::Send_uint32(), and NetworkTCPSocketHandler::SendPacket().
NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult | ( | uint16 | colour, |
const std::string & | command | ||
) |
Send the result of a console action.
colour | The colour of the result. |
command | The command that was executed. |
Definition at line 724 of file network_server.cpp.
References NETWORK_RECV_STATUS_OKAY, PACKET_SERVER_RCON, Packet::Send_string(), Packet::Send_uint16(), and NetworkTCPSocketHandler::SendPacket().