summaryrefslogtreecommitdiff
path: root/src/network/network_coordinator.h
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-07-03 11:12:28 +0200
committerPatric Stout <github@truebrain.nl>2021-07-10 20:17:07 +0200
commitaa93d76223f0411b54f5150adbe2c83c33fd61af (patch)
tree481a29b60241d08b549b2477e836c3b186276c4d /src/network/network_coordinator.h
parentb1280fd17ebaf9e4df086b63074d0bd8b8c9155d (diff)
downloadopenttd-aa93d76223f0411b54f5150adbe2c83c33fd61af.tar.xz
Add: use Game Coordinator to get latest public server listing
Diffstat (limited to 'src/network/network_coordinator.h')
-rw-r--r--src/network/network_coordinator.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/network/network_coordinator.h b/src/network/network_coordinator.h
index 1dbce063b..7399ce1fc 100644
--- a/src/network/network_coordinator.h
+++ b/src/network/network_coordinator.h
@@ -21,6 +21,10 @@
* - Game Coordinator probes server to check if it can directly connect.
* - Game Coordinator sends GC_REGISTER_ACK with type of connection.
* - Server sends every 30 seconds SERVER_UPDATE.
+ *
+ * For clients (listing):
+ * - Client sends CLIENT_LISTING.
+ * - Game Coordinator returns the full list of public servers via GC_LISTING (multiple packets).
*/
/** Class for handling the client side of the Game Coordinator connection. */
@@ -31,8 +35,13 @@ private:
protected:
bool Receive_GC_ERROR(Packet *p) override;
bool Receive_GC_REGISTER_ACK(Packet *p) override;
+ bool Receive_GC_LISTING(Packet *p) override;
public:
+ /** The idle timeout; when to close the connection because it's idle. */
+ static constexpr std::chrono::seconds IDLE_TIMEOUT = std::chrono::seconds(60);
+
+ std::chrono::steady_clock::time_point last_activity; ///< The last time there was network activity.
bool connecting; ///< Are we connecting to the Game Coordinator?
ClientNetworkCoordinatorSocketHandler() : connecting(false) {}
@@ -44,6 +53,7 @@ public:
void Register();
void SendServerUpdate();
+ void GetListing();
};
extern ClientNetworkCoordinatorSocketHandler _network_coordinator_client;