OpenTTD Source: NetworkAdminSocketHandler Class Reference

OpenTTD Source 14.0-beta3

Public Member Functions | Protected Member Functions | Protected Attributes
NetworkAdminSocketHandler Class Reference

Main socket handler for admin related connections. More...

`#include <tcp_admin.h>`

Inheritance diagram for NetworkAdminSocketHandler:

## Public Member Functions
NetworkRecvStatus | CloseConnection (bool error=true) override
| This will put this socket handler in a close state. More...
| NetworkAdminSocketHandler (SOCKET s)
| Create the admin handler for the given socket. More...
NetworkRecvStatus | ReceivePackets ()
| Do the actual receiving of packets. More...
AdminStatus | GetAdminStatus () const
| Get the status of the admin. More...
Public Member Functions inherited from NetworkTCPSocketHandler
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 (std::unique_ptr< 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...
virtual std::unique_ptr< Packet > | ReceivePacket ()
| Receives a packet for the given 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...
Public Member Functions inherited from NetworkSocketHandler
| NetworkSocketHandler ()
| Create a new unbound socket.
virtual | ~NetworkSocketHandler ()=default
| 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.

## Protected Member Functions
NetworkRecvStatus | ReceiveInvalidPacket (PacketAdminType type)
| Helper for logging receiving invalid packets. More...
virtual NetworkRecvStatus | Receive_ADMIN_JOIN (Packet &p)
| Join the admin network: string Password the server is expecting for this network. More...
virtual NetworkRecvStatus | Receive_ADMIN_QUIT (Packet &p)
| Notification to the server that this admin is quitting. More...
virtual NetworkRecvStatus | Receive_ADMIN_UPDATE_FREQUENCY (Packet &p)
| Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): uint16_t Update type (see AdminUpdateType). More...
virtual NetworkRecvStatus | Receive_ADMIN_POLL (Packet &p)
| Poll the server for certain updates, an invalid poll (e.g. More...
virtual NetworkRecvStatus | Receive_ADMIN_CHAT (Packet &p)
| Send chat as the server: uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction). More...
virtual NetworkRecvStatus | Receive_ADMIN_EXTERNAL_CHAT (Packet &p)
| Send chat from the external source: string Name of the source this message came from. More...
virtual NetworkRecvStatus | Receive_ADMIN_RCON (Packet &p)
| Execute a command on the servers console: string Command to be executed. More...
virtual NetworkRecvStatus | Receive_ADMIN_GAMESCRIPT (Packet &p)
| Send a JSON string to the current active GameScript. More...
virtual NetworkRecvStatus | Receive_ADMIN_PING (Packet &p)
| Ping the server, requiring the server to reply with a pong packet. More...
virtual NetworkRecvStatus | Receive_SERVER_FULL (Packet &p)
| The server is full (connection gets closed). More...
virtual NetworkRecvStatus | Receive_SERVER_BANNED (Packet &p)
| The source IP address is banned (connection gets closed). More...
virtual NetworkRecvStatus | Receive_SERVER_ERROR (Packet &p)
| An error was caused by this admin connection (connection gets closed). More...
virtual NetworkRecvStatus | Receive_SERVER_PROTOCOL (Packet &p)
| Inform a just joined admin about the protocol specifics: uint8_t Protocol version. More...
virtual NetworkRecvStatus | Receive_SERVER_WELCOME (Packet &p)
| Welcome a connected admin to the game: string Name of the Server. More...
virtual NetworkRecvStatus | Receive_SERVER_NEWGAME (Packet &p)
| Notification about a newgame. More...
virtual NetworkRecvStatus | Receive_SERVER_SHUTDOWN (Packet &p)
| Notification about the server shutting down. More...
virtual NetworkRecvStatus | Receive_SERVER_DATE (Packet &p)
| Send the current date of the game: uint32_t Current game date. More...
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_JOIN (Packet &p)
| Notification of a new client: uint32_t ID of the new client. More...
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_INFO (Packet &p)
| Client information of a specific client: uint32_t ID of the client. More...
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_UPDATE (Packet &p)
| Client update details on a specific client (e.g. More...
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_QUIT (Packet &p)
| Notification about a client leaving the game. More...
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_ERROR (Packet &p)
| Notification about a client error (and thus the clients disconnection). More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_NEW (Packet &p)
| Notification of a new company: uint8_t ID of the new company. More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_INFO (Packet &p)
| Company information on a specific company: uint8_t ID of the company. More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_UPDATE (Packet &p)
| Company information of a specific company: uint8_t ID of the company. More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_REMOVE (Packet &p)
| Notification about a removed company (e.g. More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_ECONOMY (Packet &p)
| Economy update of a specific company: uint8_t ID of the company. More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_STATS (Packet &p)
| Company statistics on stations and vehicles: uint8_t ID of the company. More...
virtual NetworkRecvStatus | Receive_SERVER_CHAT (Packet &p)
| Send chat from the game into the admin network: uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction). More...
virtual NetworkRecvStatus | Receive_SERVER_RCON (Packet &p)
| Result of an rcon command: uint16_t Colour as it would be used on the server or a client. More...
virtual NetworkRecvStatus | Receive_SERVER_CONSOLE (Packet &p)
| Send what would be printed on the server's console also into the admin network. More...
virtual NetworkRecvStatus | Receive_SERVER_CMD_NAMES (Packet &p)
| Send DoCommand names to the bot upon request only. More...
virtual NetworkRecvStatus | Receive_SERVER_CMD_LOGGING (Packet &p)
| Send incoming command packets to the admin network. More...
virtual NetworkRecvStatus | Receive_SERVER_PONG (Packet &p)
| Send a ping-reply (pong) to the admin that sent us the ping packet. More...
virtual NetworkRecvStatus | Receive_SERVER_RCON_END (Packet &p)
| Notify the admin connection that the rcon command has finished. More...
NetworkRecvStatus | HandlePacket (Packet &p)
| Handle the given packet, i.e. More...

## Protected Attributes
std::string | admin_name
| Name of the admin.
std::string | admin_version
| Version string of the admin.
AdminStatus | status
| Status of this admin.

## Additional Inherited Members
Data Fields inherited from NetworkTCPSocketHandler
SOCKET | sock
| The socket currently connected to.
bool | writable
| Can we write to this socket?

## Detailed Description

Main socket handler for admin related connections.

Definition at line 112 of file tcp_admin.h.

## Constructor & Destructor Documentation

## ◆ NetworkAdminSocketHandler()

NetworkAdminSocketHandler::NetworkAdminSocketHandler | ( | SOCKET | s | ) |

Create the admin handler for the given socket.

Parameters

  s | The socket to communicate over.

Definition at line 30 of file tcp_admin.cpp.

References NetworkTCPSocketHandler::sock.

## Member Function Documentation

## ◆ CloseConnection()

NetworkRecvStatus NetworkAdminSocketHandler::CloseConnection | ( | bool | error = `true` | ) |
| overridevirtual

This will put this socket handler in a close state.

It will not actually close the OS socket; use CloseSocket for this.

Parameters

  error | Whether we quit under an error condition or not.

Returns
  new status of the connection.

Reimplemented from NetworkTCPSocketHandler.

Definition at line 35 of file tcp_admin.cpp.

References NETWORK_RECV_STATUS_CLIENT_QUIT.

Referenced by HandlePacket(), ServerNetworkAdminSocketHandler::Receive_ADMIN_QUIT(), and ServerNetworkAdminSocketHandler::SendError().

## ◆ GetAdminStatus()

AdminStatus NetworkAdminSocketHandler::GetAdminStatus | ( |  | ) | const
| inline

Get the status of the admin.

Returns
  The status of the admin.

Definition at line 503 of file tcp_admin.h.

References status.

## ◆ HandlePacket()

NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket | ( | Packet & | p | ) |
| protected

Handle the given packet, i.e.

pass it to the right parser receive command.

Parameters

  p | the packet to handle.

Returns
  NetworkRecvStatus of handling.

Definition at line 46 of file tcp_admin.cpp.

References admin_name, ADMIN_PACKET_ADMIN_CHAT, ADMIN_PACKET_ADMIN_EXTERNAL_CHAT, ADMIN_PACKET_ADMIN_GAMESCRIPT, ADMIN_PACKET_ADMIN_JOIN, ADMIN_PACKET_ADMIN_PING, ADMIN_PACKET_ADMIN_POLL, ADMIN_PACKET_ADMIN_QUIT, ADMIN_PACKET_ADMIN_RCON, ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY, ADMIN_PACKET_SERVER_BANNED, ADMIN_PACKET_SERVER_CHAT, ADMIN_PACKET_SERVER_CLIENT_ERROR, ADMIN_PACKET_SERVER_CLIENT_INFO, ADMIN_PACKET_SERVER_CLIENT_JOIN, ADMIN_PACKET_SERVER_CLIENT_QUIT, ADMIN_PACKET_SERVER_CLIENT_UPDATE, ADMIN_PACKET_SERVER_CMD_LOGGING, ADMIN_PACKET_SERVER_CMD_NAMES, ADMIN_PACKET_SERVER_COMPANY_ECONOMY, ADMIN_PACKET_SERVER_COMPANY_INFO, ADMIN_PACKET_SERVER_COMPANY_NEW, ADMIN_PACKET_SERVER_COMPANY_REMOVE, ADMIN_PACKET_SERVER_COMPANY_STATS, ADMIN_PACKET_SERVER_COMPANY_UPDATE, ADMIN_PACKET_SERVER_CONSOLE, ADMIN_PACKET_SERVER_DATE, ADMIN_PACKET_SERVER_ERROR, ADMIN_PACKET_SERVER_FULL, ADMIN_PACKET_SERVER_NEWGAME, ADMIN_PACKET_SERVER_PONG, ADMIN_PACKET_SERVER_PROTOCOL, ADMIN_PACKET_SERVER_RCON, ADMIN_PACKET_SERVER_RCON_END, ADMIN_PACKET_SERVER_SHUTDOWN, ADMIN_PACKET_SERVER_WELCOME, admin_version, CloseConnection(), Debug, NetworkSocketHandler::HasClientQuit(), NETWORK_RECV_STATUS_MALFORMED_PACKET, Receive_ADMIN_CHAT(), Receive_ADMIN_EXTERNAL_CHAT(), Receive_ADMIN_GAMESCRIPT(), Receive_ADMIN_JOIN(), Receive_ADMIN_PING(), Receive_ADMIN_POLL(), Receive_ADMIN_QUIT(), Receive_ADMIN_RCON(), Receive_ADMIN_UPDATE_FREQUENCY(), Receive_SERVER_BANNED(), Receive_SERVER_CHAT(), Receive_SERVER_CLIENT_ERROR(), Receive_SERVER_CLIENT_INFO(), Receive_SERVER_CLIENT_JOIN(), Receive_SERVER_CLIENT_QUIT(), Receive_SERVER_CLIENT_UPDATE(), Receive_SERVER_CMD_LOGGING(), Receive_SERVER_CMD_NAMES(), Receive_SERVER_COMPANY_ECONOMY(), Receive_SERVER_COMPANY_INFO(), Receive_SERVER_COMPANY_NEW(), Receive_SERVER_COMPANY_REMOVE(), Receive_SERVER_COMPANY_STATS(), Receive_SERVER_COMPANY_UPDATE(), Receive_SERVER_CONSOLE(), Receive_SERVER_DATE(), Receive_SERVER_ERROR(), Receive_SERVER_FULL(), Receive_SERVER_NEWGAME(), Receive_SERVER_PONG(), Receive_SERVER_PROTOCOL(), Receive_SERVER_RCON(), Receive_SERVER_RCON_END(), Receive_SERVER_SHUTDOWN(), Receive_SERVER_WELCOME(), and Packet::Recv_uint8().

Referenced by ReceivePackets().

## ◆ Receive_ADMIN_CHAT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_CHAT | ( | Packet & | p | ) |
| protectedvirtual

Send chat as the server: uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).

uint8_t Destination type such as DESTTYPE_BROADCAST (see DestType). uint32_t ID of the destination such as company or client id. string Message.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 135 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_CHAT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_EXTERNAL_CHAT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT | ( | Packet & | p | ) |
| protectedvirtual

Send chat from the external source: string Name of the source this message came from.

uint16_t TextColour to use for the message. string Name of the user who sent the messsage. string Message.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 136 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_EXTERNAL_CHAT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_GAMESCRIPT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT | ( | Packet & | p | ) |
| protectedvirtual

Send a JSON string to the current active GameScript.

json JSON string for the GameScript.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 138 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_GAMESCRIPT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_JOIN()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_JOIN | ( | Packet & | p | ) |
| protectedvirtual

Join the admin network: string Password the server is expecting for this network.

string Name of the application being used to connect. string Version string of the application being used to connect.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 131 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_JOIN, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_PING()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_PING | ( | Packet & | p | ) |
| protectedvirtual

Ping the server, requiring the server to reply with a pong packet.

uint32_t Integer value to pass to the server, which is quoted in the reply.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 139 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_PING, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_POLL()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_POLL | ( | Packet & | p | ) |
| protectedvirtual

Poll the server for certain updates, an invalid poll (e.g.

not existent id) gets silently dropped: uint8_t AdminUpdateType the server should answer for, only if AdminUpdateFrequency ADMIN_FREQUENCY_POLL is advertised in the PROTOCOL packet. Note integer type - see "Certain Packet Information" in docs/admin_network.md. uint32_t ID relevant to the packet type, e.g.

- the client ID for ADMIN_UPDATE_CLIENT_INFO. Use UINT32_MAX to show all clients.
- the company ID for ADMIN_UPDATE_COMPANY_INFO. Use UINT32_MAX to show all companies.
  Parameters

    p | The packet that was just received.

  Returns
    The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 134 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_POLL, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_QUIT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_QUIT | ( | Packet & | p | ) |
| protectedvirtual

Notification to the server that this admin is quitting.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 132 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_QUIT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_RCON()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_RCON | ( | Packet & | p | ) |
| protectedvirtual

Execute a command on the servers console: string Command to be executed.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 137 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_RCON, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_UPDATE_FREQUENCY()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY | ( | Packet & | p | ) |
| protectedvirtual

Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): uint16_t Update type (see AdminUpdateType).

Note integer type - see "Certain Packet Information" in docs/admin_network.md. uint16_t Update frequency (see AdminUpdateFrequency), setting ADMIN_FREQUENCY_POLL is always ignored.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 133 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_BANNED()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_BANNED | ( | Packet & | p | ) |
| protectedvirtual

The source IP address is banned (connection gets closed).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 142 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_BANNED, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CHAT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CHAT | ( | Packet & | p | ) |
| protectedvirtual

Send chat from the game into the admin network: uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).

uint8_t Destination type such as DESTTYPE_BROADCAST (see DestType). uint32_t ID of the client who sent this message. string Message. uint64_t Money (only when it is a 'give money' action).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 161 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CHAT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CLIENT_ERROR()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_ERROR | ( | Packet & | p | ) |
| protectedvirtual

Notification about a client error (and thus the clients disconnection).

uint32_t ID of the client that made the error. uint8_t Error the client made (see NetworkErrorCode).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 154 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CLIENT_ERROR, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CLIENT_INFO()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_INFO | ( | Packet & | p | ) |
| protectedvirtual

Client information of a specific client: uint32_t ID of the client.

string Network address of the client. string Name of the client. uint8_t Language of the client. uint32_t Date the client joined the game. uint8_t ID of the company the client is playing as (255 for spectators).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 151 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CLIENT_INFO, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CLIENT_JOIN()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_JOIN | ( | Packet & | p | ) |
| protectedvirtual

Notification of a new client: uint32_t ID of the new client.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 150 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CLIENT_JOIN, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CLIENT_QUIT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_QUIT | ( | Packet & | p | ) |
| protectedvirtual

Notification about a client leaving the game.

uint32_t ID of the client that just left.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 153 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CLIENT_QUIT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CLIENT_UPDATE()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_UPDATE | ( | Packet & | p | ) |
| protectedvirtual

Client update details on a specific client (e.g.

after rename or move): uint32_t ID of the client. string Name of the client. uint8_t ID of the company the client is playing as (255 for spectators).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 152 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CLIENT_UPDATE, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CMD_LOGGING()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_LOGGING | ( | Packet & | p | ) |
| protectedvirtual

Send incoming command packets to the admin network.

This is for logging purposes only.

NOTICE: Data provided with this packet is not stable and will not be treated as such. Do not rely on IDs or names to be constant across different versions / revisions of OpenTTD. Data provided in this packet is for logging purposes only.

uint32_t ID of the client sending the command. uint8_t ID of the company (0..MAX_COMPANIES-1). uint16_t ID of the command. Command specific buffer with encoded parameters of variable length. The content differs per command and can change without notification. uint32_t Frame of execution.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 165 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CMD_LOGGING, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CMD_NAMES()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_NAMES | ( | Packet & | p | ) |
| protectedvirtual

Send DoCommand names to the bot upon request only.

Multiple of these packets can follow each other in order to provide all known DoCommand names.

NOTICE: Data provided with this packet is not stable and will not be treated as such. Do not rely on IDs or names to be constant across different versions / revisions of OpenTTD. Data provided in this packet is for logging purposes only.

These three fields are repeated until the packet is full: bool Data to follow. uint16_t ID of the DoCommand. string Name of DoCommand.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 164 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CMD_NAMES, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_ECONOMY()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_ECONOMY | ( | Packet & | p | ) |
| protectedvirtual

Economy update of a specific company: uint8_t ID of the company.

uint64_t Money. uint64_t Loan. int64_t Income. uint16_t Delivered cargo (this quarter). uint64_t Company value (last quarter). uint16_t Performance (last quarter). uint16_t Delivered cargo (last quarter). uint64_t Company value (previous quarter). uint16_t Performance (previous quarter). uint16_t Delivered cargo (previous quarter).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 159 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_ECONOMY, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_INFO()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_INFO | ( | Packet & | p | ) |
| protectedvirtual

Company information on a specific company: uint8_t ID of the company.

string Name of the company. string Name of the companies manager. uint8_t Main company colour. bool Company is password protected. uint32_t Year the company was inaugurated. bool Company is an AI.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 156 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_INFO, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_NEW()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_NEW | ( | Packet & | p | ) |
| protectedvirtual

Notification of a new company: uint8_t ID of the new company.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 155 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_NEW, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_REMOVE()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_REMOVE | ( | Packet & | p | ) |
| protectedvirtual

Notification about a removed company (e.g.

due to bankruptcy). uint8_t ID of the company. uint8_t Reason for being removed (see AdminCompanyRemoveReason).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 158 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_REMOVE, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_STATS()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_STATS | ( | Packet & | p | ) |
| protectedvirtual

Company statistics on stations and vehicles: uint8_t ID of the company.

uint16_t Number of trains. uint16_t Number of lorries. uint16_t Number of busses. uint16_t Number of planes. uint16_t Number of ships. uint16_t Number of train stations. uint16_t Number of lorry stations. uint16_t Number of bus stops. uint16_t Number of airports and heliports. uint16_t Number of harbours.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 160 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_STATS, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_UPDATE()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_UPDATE | ( | Packet & | p | ) |
| protectedvirtual

Company information of a specific company: uint8_t ID of the company.

string Name of the company. string Name of the companies manager. uint8_t Main company colour. bool Company is password protected. uint8_t Quarters of bankruptcy. uint8_t Owner of share 1. uint8_t Owner of share 2. uint8_t Owner of share 3. uint8_t Owner of share 4.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 157 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_UPDATE, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CONSOLE()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CONSOLE | ( | Packet & | p | ) |
| protectedvirtual

Send what would be printed on the server's console also into the admin network.

string The origin of the text, e.g. "console" for console, or "net" for network related (debug) messages. string Text as found on the console of the server.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 163 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CONSOLE, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_DATE()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_DATE | ( | Packet & | p | ) |
| protectedvirtual

Send the current date of the game: uint32_t Current game date.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 149 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_DATE, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_ERROR()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_ERROR | ( | Packet & | p | ) |
| protectedvirtual

An error was caused by this admin connection (connection gets closed).

uint8_t NetworkErrorCode the error caused.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 143 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_ERROR, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_FULL()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_FULL | ( | Packet & | p | ) |
| protectedvirtual

The server is full (connection gets closed).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 141 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_FULL, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_NEWGAME()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_NEWGAME | ( | Packet & | p | ) |
| protectedvirtual

Notification about a newgame.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 146 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_NEWGAME, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_PONG()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_PONG | ( | Packet & | p | ) |
| protectedvirtual

Send a ping-reply (pong) to the admin that sent us the ping packet.

uint32_t Integer identifier - should be the same as read from the admins ping packet.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 167 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_PONG, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_PROTOCOL()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_PROTOCOL | ( | Packet & | p | ) |
| protectedvirtual

Inform a just joined admin about the protocol specifics: uint8_t Protocol version.

bool Further protocol data follows (repeats through all update packet types). uint16_t Update packet type. uint16_t Frequencies allowed for this update packet (bitwise).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 144 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_PROTOCOL, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_RCON()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON | ( | Packet & | p | ) |
| protectedvirtual

Result of an rcon command: uint16_t Colour as it would be used on the server or a client.

string Output of the executed command.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 162 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_RCON, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_RCON_END()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON_END | ( | Packet & | p | ) |
| protectedvirtual

Notify the admin connection that the rcon command has finished.

string The command as requested by the admin connection.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 166 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_RCON_END, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_SHUTDOWN()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_SHUTDOWN | ( | Packet & | p | ) |
| protectedvirtual

Notification about the server shutting down.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 147 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_SHUTDOWN, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_WELCOME()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_WELCOME | ( | Packet & | p | ) |
| protectedvirtual

Welcome a connected admin to the game: string Name of the Server.

string OpenTTD version string. bool Server is dedicated. string Name of the Map. uint32_t Random seed of the Map. uint8_t Landscape of the Map. uint32_t Start date of the Map. uint16_t Map width. uint16_t Map height.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 145 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_WELCOME, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ ReceiveInvalidPacket()

NetworkRecvStatus NetworkAdminSocketHandler::ReceiveInvalidPacket | ( | PacketAdminType | type | ) |
| protected

Helper for logging receiving invalid packets.

Parameters

  type | The received packet type.

Returns
  The status the network should have, in this case: "malformed packet error".

Definition at line 125 of file tcp_admin.cpp.

References admin_name, admin_version, Debug, and NETWORK_RECV_STATUS_MALFORMED_PACKET.

Referenced by Receive_ADMIN_CHAT(), Receive_ADMIN_EXTERNAL_CHAT(), Receive_ADMIN_GAMESCRIPT(), Receive_ADMIN_JOIN(), Receive_ADMIN_PING(), Receive_ADMIN_POLL(), Receive_ADMIN_QUIT(), Receive_ADMIN_RCON(), Receive_ADMIN_UPDATE_FREQUENCY(), Receive_SERVER_BANNED(), Receive_SERVER_CHAT(), Receive_SERVER_CLIENT_ERROR(), Receive_SERVER_CLIENT_INFO(), Receive_SERVER_CLIENT_JOIN(), Receive_SERVER_CLIENT_QUIT(), Receive_SERVER_CLIENT_UPDATE(), Receive_SERVER_CMD_LOGGING(), Receive_SERVER_CMD_NAMES(), Receive_SERVER_COMPANY_ECONOMY(), Receive_SERVER_COMPANY_INFO(), Receive_SERVER_COMPANY_NEW(), Receive_SERVER_COMPANY_REMOVE(), Receive_SERVER_COMPANY_STATS(), Receive_SERVER_COMPANY_UPDATE(), Receive_SERVER_CONSOLE(), Receive_SERVER_DATE(), Receive_SERVER_ERROR(), Receive_SERVER_FULL(), Receive_SERVER_NEWGAME(), Receive_SERVER_PONG(), Receive_SERVER_PROTOCOL(), Receive_SERVER_RCON(), Receive_SERVER_RCON_END(), Receive_SERVER_SHUTDOWN(), and Receive_SERVER_WELCOME().

## ◆ ReceivePackets()

NetworkRecvStatus NetworkAdminSocketHandler::ReceivePackets | ( |  | ) |

Do the actual receiving of packets.

As long as HandlePacket returns OKAY packets are handled. Upon failure, or no more packets to process the last result of HandlePacket is returned.

Returns
  NetworkRecvStatus of the last handled packet.

Definition at line 109 of file tcp_admin.cpp.

References HandlePacket(), NETWORK_RECV_STATUS_OKAY, and NetworkTCPSocketHandler::ReceivePacket().

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

- src/network/core/tcp_admin.h
- src/network/core/tcp_admin.cpp