# ServerNetworkAdminSocketHandler Class Reference

Class for handling the server side of the game connection. More...

`#include <network_admin.h>`

Inheritance diagram for ServerNetworkAdminSocketHandler:

## Public Member Functions
| ServerNetworkAdminSocketHandler (SOCKET s)
| Create a new socket for the server side of the admin network.
| ~ServerNetworkAdminSocketHandler ()
| Clear everything related to this admin.
NetworkRecvStatus | SendError (NetworkErrorCode error)
NetworkRecvStatus | SendWelcome ()
NetworkRecvStatus | SendNewGame ()
NetworkRecvStatus | SendShutdown ()
NetworkRecvStatus | SendDate ()
NetworkRecvStatus | SendClientJoin (ClientID client_id)
NetworkRecvStatus | SendClientInfo (const NetworkClientInfo *ci)
NetworkRecvStatus | SendClientUpdate (const NetworkClientInfo *ci)
NetworkRecvStatus | SendClientQuit (ClientID client_id)
NetworkRecvStatus | SendClientError (ClientID client_id, NetworkErrorCode error)
NetworkRecvStatus | SendCompanyNew (CompanyID company_id)
NetworkRecvStatus | SendCompanyInfo (const Company *c)
NetworkRecvStatus | SendCompanyUpdate (const Company *c)
NetworkRecvStatus | SendCompanyRemove (CompanyID company_id, AdminCompanyRemoveReason bcrr)
NetworkRecvStatus | SendCompanyEconomy ()
NetworkRecvStatus | SendCompanyStats ()
NetworkRecvStatus | SendChat (NetworkAction action, DestType desttype, ClientID client_id, const char *msg, int64 data)
NetworkRecvStatus | SendRcon (uint16 colour, const char *command)
NetworkRecvStatus | SendConsole (const char *origin, const char *command)
NetworkRecvStatus | SendCmdNames ()
NetworkRecvStatus | SendCmdLogging (ClientID client_id, const CommandPacket *cp)
## Static Public Member Functions
static void | Send ()
| Send the packets for the server sockets.
static void | AcceptConnection (SOCKET s, const NetworkAddress &address)
static bool | AllowConnection ()
| Whether a connection is allowed or not at this moment.
static void | WelcomeAll ()
| Send a Welcome packet to all connected admins.
static const char * | GetName ()
| Get the name used by the listener.
## Data Fields
AdminUpdateFrequency | update_frequency [ADMIN_UPDATE_END]
| Admin requested update intervals.
uint32 | realtime_connect
| Time of connection.
NetworkAddress | address
| Address of the admin.
## Protected Member Functions
| DECLARE_ADMIN_RECEIVE_COMMAND (ADMIN_PACKET_ADMIN_JOIN)
| Join the admin network: string Password the server is expecting for this network.
| DECLARE_ADMIN_RECEIVE_COMMAND (ADMIN_PACKET_ADMIN_QUIT)
| Notification to the server that this admin is quitting.
| DECLARE_ADMIN_RECEIVE_COMMAND (ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY)
| Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): uint16 Update type (see AdminUpdateType).
| DECLARE_ADMIN_RECEIVE_COMMAND (ADMIN_PACKET_ADMIN_POLL)
| Poll the server for certain updates, an invalid poll (e.g.
| DECLARE_ADMIN_RECEIVE_COMMAND (ADMIN_PACKET_ADMIN_CHAT)
| Send chat as the server: uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).
| DECLARE_ADMIN_RECEIVE_COMMAND (ADMIN_PACKET_ADMIN_RCON)
| Execute a command on the servers console: string Command to be executed.
NetworkRecvStatus | SendProtocol ()

## Detailed Description

Class for handling the server side of the game connection.

Definition at line 28 of file network_admin.h.

## Constructor & Destructor Documentation

ServerNetworkAdminSocketHandler::ServerNetworkAdminSocketHandler | ( | SOCKET | s | ) |

Create a new socket for the server side of the admin network.

Parameters:

  | s | The socket to connect with.

Definition at line 61 of file network_admin.cpp.

References _network_admins_connected, _realtime_tick, ADMIN_STATUS_INACTIVE, realtime_connect, and NetworkAdminSocketHandler::status.

## Member Function Documentation

bool ServerNetworkAdminSocketHandler::AllowConnection | ( |  | ) | `[static]`

Whether a connection is allowed or not at this moment.

Returns:
  Whether the connection is allowed.

Definition at line 82 of file network_admin.cpp.

References _network_admins_connected, _settings_client, NetworkSettings::admin_password, MAX_ADMINS, ClientSettings::network, and StrEmpty().

ServerNetworkAdminSocketHandler::DECLARE_ADMIN_RECEIVE_COMMAND | ( | ADMIN_PACKET_ADMIN_CHAT |  | ) | `[protected]`

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

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

Reimplemented from NetworkAdminSocketHandler.

ServerNetworkAdminSocketHandler::DECLARE_ADMIN_RECEIVE_COMMAND | ( | ADMIN_PACKET_ADMIN_POLL |  | ) | `[protected]`

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

not existent id) gets silently dropped: uint8 AdminUpdateType the server should answer for, only if AdminUpdateFrequency ADMIN_FREQUENCY_POLL is advertised in the PROTOCOL packet. uint32 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.

Reimplemented from NetworkAdminSocketHandler.

ServerNetworkAdminSocketHandler::DECLARE_ADMIN_RECEIVE_COMMAND | ( | ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY |  | ) | `[protected]`

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

uint16 Update frequency (see AdminUpdateFrequency), setting ADMIN_FREQUENCY_POLL is always ignored.

Reimplemented from NetworkAdminSocketHandler.

ServerNetworkAdminSocketHandler::DECLARE_ADMIN_RECEIVE_COMMAND | ( | ADMIN_PACKET_ADMIN_JOIN |  | ) | `[protected]`

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.

Reimplemented from NetworkAdminSocketHandler.

static const char* ServerNetworkAdminSocketHandler::GetName | ( |  | ) | `[inline, static]`

Get the name used by the listener.

Returns:
  the name to show in debug logs and the like.

Definition at line 79 of file network_admin.h.

void ServerNetworkAdminSocketHandler::Send | ( |  | ) | `[static]`

Send the packets for the server sockets.

Definition at line 88 of file network_admin.cpp.

References _realtime_tick, ADMIN_AUTHORISATION_TIMEOUT, ADMIN_STATUS_INACTIVE, NetworkAdminSocketHandler::CloseConnection(), DEBUG, realtime_connect, NetworkTCPSocketHandler::SendPackets(), NetworkAdminSocketHandler::status, and NetworkTCPSocketHandler::writable.

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

- src/network/network_admin.h
- src/network/network_admin.cpp