From f94fb9377910c63fc8e1ea0ede1d96603e4d8862 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Wed, 5 May 2021 23:21:14 +0200 Subject: Codechange: use connection_string in favour of NetworkAddress (#9197) We now resolve the connection_string to a NetworkAddress in a much later state. This means there are fewer places constructing a NetworkAddress. The main benefit of this is in later PRs that introduce different types of NetworkAddresses. Storing this in things like NetworkGameList is rather complex, especially as NetworkAddress has to be mutable at all times. Additionally, the NetworkAddress is a complex object to store simple information: how to connect to this server. --- src/network/network_content.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/network/network_content.cpp') diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index a208f3c6e..528b7bd77 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -343,8 +343,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const Conten this->http_response_index = -1; - NetworkAddress address(NETWORK_CONTENT_MIRROR_HOST, NETWORK_CONTENT_MIRROR_PORT); - new NetworkHTTPContentConnecter(address, this, NETWORK_CONTENT_MIRROR_URL, content_request); + new NetworkHTTPContentConnecter(NETWORK_CONTENT_MIRROR_HOST, this, NETWORK_CONTENT_MIRROR_URL, content_request); /* NetworkHTTPContentConnecter takes over freeing of content_request! */ } @@ -744,7 +743,7 @@ public: * Initiate the connecting. * @param address The address of the server. */ - NetworkContentConnecter(const NetworkAddress &address) : TCPConnecter(address) {} + NetworkContentConnecter(const std::string &connection_string) : TCPConnecter(connection_string, NETWORK_CONTENT_SERVER_PORT) {} void OnFailure() override { @@ -770,7 +769,7 @@ void ClientNetworkContentSocketHandler::Connect() { if (this->sock != INVALID_SOCKET || this->isConnecting) return; this->isConnecting = true; - new NetworkContentConnecter(NetworkAddress(NETWORK_CONTENT_SERVER_HOST, NETWORK_CONTENT_SERVER_PORT, AF_UNSPEC)); + new NetworkContentConnecter(NETWORK_CONTENT_SERVER_HOST); } /** -- cgit v1.2.3-54-g00ecf