OpenTTD
network_admin.h
Go to the documentation of this file.
1 /* $Id: network_admin.h 25588 2013-07-11 20:31:39Z planetmaker $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8  */
9 
12 #ifndef NETWORK_ADMIN_H
13 #define NETWORK_ADMIN_H
14 
15 #ifdef ENABLE_NETWORK
16 
17 #include "network_internal.h"
18 #include "core/tcp_listen.h"
19 #include "core/tcp_admin.h"
20 
22 
27 
29 class ServerNetworkAdminSocketHandler : public NetworkAdminSocketPool::PoolItem<&_networkadminsocket_pool>, public NetworkAdminSocketHandler, public TCPListenHandler<ServerNetworkAdminSocketHandler, ADMIN_PACKET_SERVER_FULL, ADMIN_PACKET_SERVER_BANNED> {
30 protected:
39 
41  NetworkRecvStatus SendPong(uint32 d1);
42 public:
46 
49 
54 
57  NetworkRecvStatus SendClientInfo(const NetworkClientSocket *cs, const NetworkClientInfo *ci);
67 
68  NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const char *msg, int64 data);
69  NetworkRecvStatus SendRcon(uint16 colour, const char *command);
70  NetworkRecvStatus SendConsole(const char *origin, const char *command);
71  NetworkRecvStatus SendGameScript(const char *json);
74  NetworkRecvStatus SendRconEnd(const char *command);
75 
76  static void Send();
77  static void AcceptConnection(SOCKET s, const NetworkAddress &address);
78  static bool AllowConnection();
79  static void WelcomeAll();
80 
85  static const char *GetName()
86  {
87  return "admin";
88  }
89 };
90 
96 #define FOR_ALL_ADMIN_SOCKETS_FROM(var, start) FOR_ALL_ITEMS_FROM(ServerNetworkAdminSocketHandler, adminsocket_index, var, start)
97 
102 #define FOR_ALL_ADMIN_SOCKETS(var) FOR_ALL_ADMIN_SOCKETS_FROM(var, 0)
103 
108 #define FOR_ALL_ACTIVE_ADMIN_SOCKETS(var) \
109  FOR_ALL_ADMIN_SOCKETS(var) \
110  if (var->GetAdminStatus() == ADMIN_STATUS_ACTIVE)
111 
112 void NetworkAdminClientInfo(const NetworkClientSocket *cs, bool new_client = false);
114 void NetworkAdminClientQuit(ClientID client_id);
115 void NetworkAdminClientError(ClientID client_id, NetworkErrorCode error_code);
116 void NetworkAdminCompanyInfo(const Company *company, bool new_company);
117 void NetworkAdminCompanyUpdate(const Company *company);
119 
120 void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const char *msg, int64 data = 0, bool from_admin = false);
122 void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const char *string);
123 void NetworkAdminConsole(const char *origin, const char *string);
124 void NetworkAdminGameScript(const char *json);
125 void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket *cp);
126 
127 #endif /* ENABLE_NETWORK */
128 #endif /* NETWORK_ADMIN_H */