summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-10-17 17:37:26 +0000
committerrubidium <rubidium@openttd.org>2010-10-17 17:37:26 +0000
commitfe44944f326b08e6b005aef8bfcf546467b5b136 (patch)
tree5cfe8965da332f4d7299a4f11b86dfe4779a9aa7 /src/network/core
parent901c4a56bd29b687bee0cd7ffa49e8c9a08b9bf9 (diff)
downloadopenttd-fe44944f326b08e6b005aef8bfcf546467b5b136.tar.xz
(svn r20969) -Add: client info change notification to remote admins (dihedral)
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/tcp_admin.cpp10
-rw-r--r--src/network/core/tcp_admin.h47
2 files changed, 56 insertions, 1 deletions
diff --git a/src/network/core/tcp_admin.cpp b/src/network/core/tcp_admin.cpp
index 29cd251ed..ee254968a 100644
--- a/src/network/core/tcp_admin.cpp
+++ b/src/network/core/tcp_admin.cpp
@@ -64,6 +64,11 @@ NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet *p)
ADMIN_COMMAND(ADMIN_PACKET_SERVER_SHUTDOWN)
ADMIN_COMMAND(ADMIN_PACKET_SERVER_DATE)
+ ADMIN_COMMAND(ADMIN_PACKET_SERVER_CLIENT_JOIN)
+ ADMIN_COMMAND(ADMIN_PACKET_SERVER_CLIENT_INFO)
+ ADMIN_COMMAND(ADMIN_PACKET_SERVER_CLIENT_UPDATE)
+ ADMIN_COMMAND(ADMIN_PACKET_SERVER_CLIENT_QUIT)
+ ADMIN_COMMAND(ADMIN_PACKET_SERVER_CLIENT_ERROR)
default:
if (this->HasClientQuit()) {
@@ -123,5 +128,10 @@ DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_NEWGAME)
DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_SHUTDOWN)
DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_DATE)
+DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_JOIN)
+DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_INFO)
+DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_UPDATE)
+DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_QUIT)
+DEFINE_UNAVAILABLE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_ERROR)
#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h
index f93b5c388..656fa9503 100644
--- a/src/network/core/tcp_admin.h
+++ b/src/network/core/tcp_admin.h
@@ -40,6 +40,11 @@ enum PacketAdminType {
ADMIN_PACKET_SERVER_SHUTDOWN, ///< The server tells the admin its shutting down.
ADMIN_PACKET_SERVER_DATE, ///< The server tells the admin what the current game date is.
+ ADMIN_PACKET_SERVER_CLIENT_JOIN, ///< The server tells the admin that a client has joined.
+ ADMIN_PACKET_SERVER_CLIENT_INFO, ///< The server gives the admin information about a client.
+ ADMIN_PACKET_SERVER_CLIENT_UPDATE, ///< The server gives the admin an information update on a client.
+ ADMIN_PACKET_SERVER_CLIENT_QUIT, ///< The server tells the admin that a client quit.
+ ADMIN_PACKET_SERVER_CLIENT_ERROR, ///< The server tells the admin that a client caused an error.
INVALID_ADMIN_PACKET = 0xFF, ///< An invalid marker for admin packets.
};
@@ -54,6 +59,7 @@ enum AdminStatus {
/** Update types an admin can register a frequency for */
enum AdminUpdateType {
ADMIN_UPDATE_DATE, ///< Updates about the date of the game.
+ ADMIN_UPDATE_CLIENT_INFO, ///< Updates about the information of clients.
ADMIN_UPDATE_END ///< Must ALWAYS be on the end of this list!! (period)
};
@@ -102,7 +108,8 @@ 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.
+ * uint32 ID relevant to the packet type, e.g.
+ * - the client ID for #ADMIN_UPDATE_CLIENT_INFO. Use UINT32_MAX to show all clients.
*/
DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_ADMIN_POLL);
@@ -161,6 +168,44 @@ protected:
*/
DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_DATE);
+ /**
+ * Notification of a new client:
+ * uint32 ID of the new client.
+ */
+ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_JOIN);
+
+ /**
+ * Client information of a specific client:
+ * uint32 ID of the client.
+ * string Network address of the client.
+ * string Name of the client.
+ * uint8 Language of the client.
+ * uint32 Date the client joined the game.
+ * uint8 ID of the company the client is playing as (255 for spectators).
+ */
+ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_INFO);
+
+ /**
+ * Client update details on a specific client (e.g. after rename or move):
+ * uint32 ID of the client.
+ * string Name of the client.
+ * uint8 ID of the company the client is playing as (255 for spectators).
+ */
+ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_UPDATE);
+
+ /**
+ * Notification about a client leaving the game.
+ * uint32 ID of the client that just left.
+ */
+ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_QUIT);
+
+ /**
+ * Notification about a client error (and thus the clients disconnection).
+ * uint32 ID of the client that made the error.
+ * uint8 Error the client made (see NetworkErrorCode).
+ */
+ DECLARE_ADMIN_RECEIVE_COMMAND(ADMIN_PACKET_SERVER_CLIENT_ERROR);
+
NetworkRecvStatus HandlePacket(Packet *p);
public:
NetworkRecvStatus CloseConnection(bool error = true);