OpenTTD
Functions | Variables
network_admin.cpp File Reference

Server part of the admin network protocol. More...

#include "../stdafx.h"
#include "../strings_func.h"
#include "../date_func.h"
#include "network_admin.h"
#include "network_base.h"
#include "network_server.h"
#include "../command_func.h"
#include "../company_base.h"
#include "../console_func.h"
#include "../core/pool_func.hpp"
#include "../map_func.h"
#include "../rev.h"
#include "../game/game.hpp"
#include "../safeguards.h"

Go to the source code of this file.

Functions

 assert_compile (lengthof(_admin_update_type_frequencies)==ADMIN_UPDATE_END)
 Sanity check.
void NetworkAdminClientInfo (const NetworkClientSocket *cs, bool new_client)
 Notify the admin network of a new client (if they did opt in for the respective update).
void NetworkAdminClientUpdate (const NetworkClientInfo *ci)
 Notify the admin network of a client update (if they did opt in for the respective update).
void NetworkAdminClientQuit (ClientID client_id)
 Notify the admin network that a client quit (if they have opt in for the respective update).
void NetworkAdminClientError (ClientID client_id, NetworkErrorCode error_code)
 Notify the admin network of a client error (if they have opt in for the respective update).
void NetworkAdminCompanyInfo (const Company *company, bool new_company)
 Notify the admin network of company details.
void NetworkAdminCompanyUpdate (const Company *company)
 Notify the admin network of company updates.
void NetworkAdminCompanyRemove (CompanyID company_id, AdminCompanyRemoveReason bcrr)
 Notify the admin network of a company to be removed (including the reason why).
void NetworkAdminChat (NetworkAction action, DestType desttype, ClientID client_id, const char *msg, int64 data, bool from_admin)
 Send chat to the admin network (if they did opt in for the respective update).
void NetworkServerSendAdminRcon (AdminIndex admin_index, TextColour colour_code, const char *string)
 Pass the rcon reply to the admin.
void NetworkAdminConsole (const char *origin, const char *string)
 Send console to the admin network (if they did opt in for the respective update).
void NetworkAdminGameScript (const char *json)
 Send GameScript JSON to the admin network (if they did opt in for the respective update).
void NetworkAdminCmdLogging (const NetworkClientSocket *owner, const CommandPacket *cp)
 Distribute CommandPacket details over the admin network for logging purposes.
void NetworkAdminUpdate (AdminUpdateFrequency freq)
 Send (push) updates to the admin network as they have registered for these updates.

Variables

AdminIndex _redirect_console_to_admin = INVALID_ADMIN_ID
 Redirection of the (remote) console to the admin.
byte _network_admins_connected = 0
 The amount of admins connected.
NetworkAdminSocketPool _networkadminsocket_pool ("NetworkAdminSocket")
 The pool with sockets/clients.
static const int ADMIN_AUTHORISATION_TIMEOUT = 10000
 The timeout for authorisation of the client.
static const AdminUpdateFrequency _admin_update_type_frequencies []
 Frequencies, which may be registered for a certain update type.

Detailed Description

Server part of the admin network protocol.

Definition in file network_admin.cpp.

Function Documentation

Sanity check.

void NetworkAdminClientError ( ClientID  client_id,
NetworkErrorCode  error_code 
)

Notify the admin network of a client error (if they have opt in for the respective update).

Parameters
client_idthe client that made the error.
error_codethe error that was caused.

Definition at line 872 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CLIENT_INFO, FOR_ALL_ACTIVE_ADMIN_SOCKETS, ServerNetworkAdminSocketHandler::SendClientError(), and ServerNetworkAdminSocketHandler::update_frequency.

Referenced by ServerNetworkGameSocketHandler::CloseConnection(), ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(), and ServerNetworkGameSocketHandler::SendError().

void NetworkAdminClientInfo ( const NetworkClientSocket cs,
bool  new_client 
)

Notify the admin network of a new client (if they did opt in for the respective update).

Parameters
csthe client info.
new_clientif this is a new client, send the respective packet too.

Definition at line 826 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CLIENT_INFO, FOR_ALL_ACTIVE_ADMIN_SOCKETS, ServerNetworkAdminSocketHandler::SendClientInfo(), ServerNetworkAdminSocketHandler::SendClientJoin(), and ServerNetworkAdminSocketHandler::update_frequency.

Referenced by ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK().

void NetworkAdminClientQuit ( ClientID  client_id)

Notify the admin network that a client quit (if they have opt in for the respective update).

Parameters
client_idof the client that quit.

Definition at line 857 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CLIENT_INFO, FOR_ALL_ACTIVE_ADMIN_SOCKETS, ServerNetworkAdminSocketHandler::SendClientQuit(), and ServerNetworkAdminSocketHandler::update_frequency.

Referenced by ServerNetworkGameSocketHandler::Receive_CLIENT_QUIT().

void NetworkAdminClientUpdate ( const NetworkClientInfo ci)

Notify the admin network of a client update (if they did opt in for the respective update).

Parameters
cithe client info.

Definition at line 843 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CLIENT_INFO, FOR_ALL_ACTIVE_ADMIN_SOCKETS, ServerNetworkAdminSocketHandler::SendClientUpdate(), and ServerNetworkAdminSocketHandler::update_frequency.

Referenced by NetworkUpdateClientInfo().

void NetworkAdminCmdLogging ( const NetworkClientSocket owner,
const CommandPacket cp 
)

Distribute CommandPacket details over the admin network for logging purposes.

Parameters
ownerThe owner of the CommandPacket (who sent us the CommandPacket).
cpThe CommandPacket to be distributed.

Definition at line 995 of file network_admin.cpp.

References _network_own_client_id, ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CMD_LOGGING, FOR_ALL_ACTIVE_ADMIN_SOCKETS, ServerNetworkAdminSocketHandler::SendCmdLogging(), and ServerNetworkAdminSocketHandler::update_frequency.

Referenced by DistributeQueue().

void NetworkAdminCompanyInfo ( const Company company,
bool  new_company 
)

Notify the admin network of company details.

Parameters
companythe company of which details will be sent into the admin network.
new_companywhether this is a new company or not.

Definition at line 887 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_COMPANY_INFO, DEBUG, FOR_ALL_ACTIVE_ADMIN_SOCKETS, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, ServerNetworkAdminSocketHandler::SendCompanyInfo(), ServerNetworkAdminSocketHandler::SendCompanyNew(), and ServerNetworkAdminSocketHandler::update_frequency.

Referenced by NetworkServerNewCompany().

void NetworkAdminCompanyRemove ( CompanyID  company_id,
AdminCompanyRemoveReason  bcrr 
)

Notify the admin network of a company to be removed (including the reason why).

Parameters
company_idID of the company that got removed.
bcrrthe reason why the company got removed (e.g. bankruptcy).

Definition at line 926 of file network_admin.cpp.

References FOR_ALL_ACTIVE_ADMIN_SOCKETS, and ServerNetworkAdminSocketHandler::SendCompanyRemove().

Referenced by CompanyAdminRemove().

void NetworkAdminCompanyUpdate ( const Company company)

Notify the admin network of company updates.

Parameters
companycompany of which updates are going to be sent into the admin network.

Definition at line 909 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_COMPANY_INFO, FOR_ALL_ACTIVE_ADMIN_SOCKETS, ServerNetworkAdminSocketHandler::SendCompanyUpdate(), and ServerNetworkAdminSocketHandler::update_frequency.

Referenced by CompanyAdminUpdate(), and NetworkServerUpdateCompanyPassworded().

void NetworkAdminConsole ( const char *  origin,
const char *  string 
)

Send console to the admin network (if they did opt in for the respective update).

Parameters
originthe origin of the message.
stringthe message as printed on the console.

Definition at line 966 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CONSOLE, FOR_ALL_ACTIVE_ADMIN_SOCKETS, ServerNetworkAdminSocketHandler::SendConsole(), and ServerNetworkAdminSocketHandler::update_frequency.

Referenced by debug_print(), and IConsolePrint().

void NetworkAdminGameScript ( const char *  json)

Send GameScript JSON to the admin network (if they did opt in for the respective update).

Parameters
jsonThe JSON data as received from the GameScript.

Definition at line 980 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_GAMESCRIPT, FOR_ALL_ACTIVE_ADMIN_SOCKETS, ServerNetworkAdminSocketHandler::SendGameScript(), and ServerNetworkAdminSocketHandler::update_frequency.

void NetworkAdminUpdate ( AdminUpdateFrequency  freq)
void NetworkServerSendAdminRcon ( AdminIndex  admin_index,
TextColour  colour_code,
const char *  string 
)

Pass the rcon reply to the admin.

Parameters
admin_indexThe admin to give the reply.
colour_codeThe colour of the string.
stringThe string to show.

Definition at line 956 of file network_admin.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_networkadminsocket_pool >::Get().

Referenced by IConsolePrint().

Variable Documentation

const AdminUpdateFrequency _admin_update_type_frequencies[]
static
byte _network_admins_connected = 0
NetworkAdminSocketPool _networkadminsocket_pool("NetworkAdminSocket")

The pool with sockets/clients.

AdminIndex _redirect_console_to_admin = INVALID_ADMIN_ID

Redirection of the (remote) console to the admin.

Definition at line 34 of file network_admin.cpp.

Referenced by IConsolePrint(), ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON(), and ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler().

const int ADMIN_AUTHORISATION_TIMEOUT = 10000
static

The timeout for authorisation of the client.

Definition at line 44 of file network_admin.cpp.

Referenced by ServerNetworkAdminSocketHandler::Send().