Data Structures | Defines | Typedefs | Functions | Variables

# network_admin.h File Reference

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

`#include "network_internal.h"`
`#include "core/tcp_listen.h"`
`#include "core/tcp_admin.h"`

Go to the source code of this file.

## Data Structures
class | ServerNetworkAdminSocketHandler
| Class for handling the server side of the game connection. More...
## Defines
#define | FOR_ALL_ADMIN_SOCKETS_FROM(var, start) FOR_ALL_ITEMS_FROM(ServerNetworkAdminSocketHandler, adminsocket_index, var, start)
| Iterate over all the sockets from a given starting point.
#define | FOR_ALL_ADMIN_SOCKETS(var) FOR_ALL_ADMIN_SOCKETS_FROM(var, 0)
| Iterate over all the sockets.
#define | FOR_ALL_ACTIVE_ADMIN_SOCKETS(var)
| Iterate over all the active sockets.
## Typedefs
typedef Pool < ServerNetworkAdminSocketHandler, AdminIndex, 2, MAX_ADMINS, PT_NADMIN > | NetworkAdminSocketPool
| Pool with all admin connections.
## Functions
void | NetworkAdminClientInfo (const NetworkClientSocket *cs, bool new_client=false)
| 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=0, bool from_admin=false)
| Send chat to the admin network (if they did opt in for the respective update).
void | NetworkAdminUpdate (AdminUpdateFrequency freq)
| Send (push) updates to the admin network as they have registered for these updates.
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.
## Variables
AdminIndex | _redirect_console_to_admin
| Redirection of the (remote) console to the admin.
NetworkAdminSocketPool | _networkadminsocket_pool
| The pool with sockets/clients.

## Detailed Description

Server part of the admin network protocol.

Definition in file network_admin.h.

## Define Documentation

#define FOR_ALL_ACTIVE_ADMIN_SOCKETS | ( |  | var | ) |

Value:

    FOR_ALL_ADMIN_SOCKETS(var) \
        if (var->GetAdminStatus() == ADMIN_STATUS_ACTIVE)

Iterate over all the active sockets.

Parameters:

  | var | The variable to iterate with.

Definition at line 108 of file network_admin.h.

Referenced by NetworkAdminChat(), NetworkAdminClientError(), NetworkAdminClientInfo(), NetworkAdminClientQuit(), NetworkAdminClientUpdate(), NetworkAdminCmdLogging(), NetworkAdminCompanyInfo(), NetworkAdminCompanyRemove(), NetworkAdminCompanyUpdate(), NetworkAdminConsole(), NetworkAdminGameScript(), NetworkAdminUpdate(), NetworkDisconnect(), and ServerNetworkAdminSocketHandler::WelcomeAll().

#define FOR_ALL_ADMIN_SOCKETS | ( |  | var | ) | FOR_ALL_ADMIN_SOCKETS_FROM(var, 0)

Iterate over all the sockets.

Parameters:

  | var | The variable to iterate with.

Definition at line 102 of file network_admin.h.

Referenced by NetworkClose(), and ServerNetworkAdminSocketHandler::Send().

#define FOR_ALL_ADMIN_SOCKETS_FROM | ( |  | var,
|  |  | start |
| ) |  |  | FOR_ALL_ITEMS_FROM(ServerNetworkAdminSocketHandler, adminsocket_index, var, start)

Iterate over all the sockets from a given starting point.

Parameters:

  | var | The variable to iterate with.
  | start | The start of the iteration.

Definition at line 96 of file network_admin.h.

## Typedef Documentation

typedef Pool<ServerNetworkAdminSocketHandler, AdminIndex, 2, MAX_ADMINS, PT_NADMIN> NetworkAdminSocketPool

Pool with all admin connections.

Definition at line 23 of file network_admin.h.

## Function Documentation

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_id | the client that made the error.
  | error_code | the error that was caused.

Definition at line 870 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::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:

  | cs | the client info.
  | new_client | if this is a new client, send the respective packet too.

Definition at line 824 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.

void NetworkAdminClientQuit | ( | ClientID | client_id | ) |

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

Parameters:

  | client_id | of the client that quit.

Definition at line 855 of file network_admin.cpp.

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

void NetworkAdminClientUpdate | ( | const NetworkClientInfo * | ci | ) |

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

Parameters:

  | ci | the client info.

Definition at line 841 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:

  | owner | The owner of the CommandPacket (who sent us the CommandPacket).
  | cp | The CommandPacket to be distributed.

Definition at line 993 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:

  | company | the company of which details will be sent into the admin network.
  | new_company | whether this is a new company or not.

Definition at line 885 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_id | ID of the company that got removed.
  | bcrr | the reason why the company got removed (e.g. bankruptcy).

Definition at line 924 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:

  | company | company of which updates are going to be sent into the admin network.

Definition at line 907 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:

  | origin | the origin of the message.
  | string | the message as printed on the console.

Definition at line 964 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:

  | json | The JSON data as received from the GameScript.

Definition at line 978 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 | ) |

Send (push) updates to the admin network as they have registered for these updates.

Parameters:

  | freq | the frequency to be processed.

Definition at line 1020 of file network_admin.cpp.

References ADMIN_UPDATE_COMPANY_ECONOMY, ADMIN_UPDATE_COMPANY_STATS, ADMIN_UPDATE_DATE, FOR_ALL_ACTIVE_ADMIN_SOCKETS, ServerNetworkAdminSocketHandler::SendCompanyEconomy(), ServerNetworkAdminSocketHandler::SendCompanyStats(), ServerNetworkAdminSocketHandler::SendDate(), and ServerNetworkAdminSocketHandler::update_frequency.

Referenced by NetworkServerDailyLoop(), NetworkServerMonthlyLoop(), and NetworkServerYearlyLoop().

void NetworkServerSendAdminRcon | ( | AdminIndex | admin_index,
|  | TextColour | colour_code,
|  | const char * | string |
| ) |  |  |

Pass the rcon reply to the admin.

Parameters:

  | admin_index | The admin to give the reply.
  | colour_code | The colour of the string.
  | string | The string to show.

Definition at line 954 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

NetworkAdminSocketPool _networkadminsocket_pool

The pool with sockets/clients.

AdminIndex _redirect_console_to_admin

Redirection of the (remote) console to the admin.

Definition at line 32 of file network_admin.cpp.

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