summaryrefslogtreecommitdiff
path: root/src/network/network_coordinator.h
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-05-05 10:47:01 +0200
committerPatric Stout <github@truebrain.nl>2021-07-20 19:57:23 +0200
commitfa1e27994dd1284f6fefbe08c47a5c4145ccf00d (patch)
treebbe8fab946192e5667ef176673590d2fae60e969 /src/network/network_coordinator.h
parent8a361340037d6908c9a4df10aefdb58860a22b80 (diff)
downloadopenttd-fa1e27994dd1284f6fefbe08c47a5c4145ccf00d.tar.xz
Feature: allow the use of TURN to connect client and server together
TURN is a last resort, used only if all other methods failed. TURN is a relay approach to connect client and server together, where openttd.org (by default) is the middleman. It is very unlikely either the client or server cannot connect to the STUN server, as they are both already connected to the Game Coordinator. But in the odd case it does fail, estabilishing the connection fails without any further possibility to recover.
Diffstat (limited to 'src/network/network_coordinator.h')
-rw-r--r--src/network/network_coordinator.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/network/network_coordinator.h b/src/network/network_coordinator.h
index 6a7c79e70..42e16d91d 100644
--- a/src/network/network_coordinator.h
+++ b/src/network/network_coordinator.h
@@ -12,6 +12,7 @@
#include "core/tcp_coordinator.h"
#include "network_stun.h"
+#include "network_turn.h"
#include <map>
/**
@@ -42,6 +43,10 @@
* - a) Server/client connect, client sends CLIENT_CONNECTED to Game Coordinator.
* - b) Server/client connect fails, both send SERCLI_CONNECT_FAILED to Game Coordinator.
* - Game Coordinator tries other combination if available.
+ * 3) TURN?
+ * - Game Coordinator sends GC_TURN_CONNECT to server/client.
+ * - a) Server/client connect, client sends CLIENT_CONNECTED to Game Coordinator.
+ * - b) Server/client connect fails, both send SERCLI_CONNECT_FAILED to Game Coordinator.
* - If all fails, Game Coordinator sends GC_CONNECT_FAILED to indicate no connection is possible.
*/
@@ -52,6 +57,7 @@ private:
std::map<std::string, TCPServerConnecter *> connecter; ///< Based on tokens, the current connecters that are pending.
std::map<std::string, TCPServerConnecter *> connecter_pre; ///< Based on invite codes, the current connecters that are pending.
std::map<std::string, std::map<int, std::unique_ptr<ClientNetworkStunSocketHandler>>> stun_handlers; ///< All pending STUN handlers, stored by token:family.
+ std::map<std::string, std::unique_ptr<ClientNetworkTurnSocketHandler>> turn_handlers; ///< Pending TURN handler (if any), stored by token.
TCPConnecter *game_connecter = nullptr; ///< Pending connecter to the game server.
uint32 newgrf_lookup_table_cursor = 0; ///< Last received cursor for the #GameInfoNewGRFLookupTable updates.
@@ -67,6 +73,7 @@ protected:
bool Receive_GC_STUN_REQUEST(Packet *p) override;
bool Receive_GC_STUN_CONNECT(Packet *p) override;
bool Receive_GC_NEWGRF_LOOKUP(Packet *p) override;
+ bool Receive_GC_TURN_CONNECT(Packet *p) override;
public:
/** The idle timeout; when to close the connection because it's idle. */
@@ -88,12 +95,14 @@ public:
void CloseToken(const std::string &token);
void CloseAllConnections();
void CloseStunHandler(const std::string &token, uint8 family = AF_UNSPEC);
+ void CloseTurnHandler(const std::string &token);
void Register();
void SendServerUpdate();
void GetListing();
void ConnectToServer(const std::string &invite_code, TCPServerConnecter *connecter);
+ void StartTurnConnection(std::string &token);
};
extern ClientNetworkCoordinatorSocketHandler _network_coordinator_client;