mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Remove empty destructor and use member init for ClientNetworkContentSocketHandler.
parent
20d83677eb
commit
3347919fb2
|
@ -707,25 +707,6 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr<char[]> da
|
||||||
#undef check_and_terminate
|
#undef check_and_terminate
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a socket handler to handle the connection.
|
|
||||||
*/
|
|
||||||
ClientNetworkContentSocketHandler::ClientNetworkContentSocketHandler() :
|
|
||||||
NetworkContentSocketHandler(),
|
|
||||||
http_response_index(-2),
|
|
||||||
cur_file(std::nullopt),
|
|
||||||
cur_info(nullptr),
|
|
||||||
is_connecting(false),
|
|
||||||
is_cancelled(false)
|
|
||||||
{
|
|
||||||
this->last_activity = std::chrono::steady_clock::now();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Clear up the mess ;) */
|
|
||||||
ClientNetworkContentSocketHandler::~ClientNetworkContentSocketHandler()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Connect to the content server. */
|
/** Connect to the content server. */
|
||||||
class NetworkContentConnecter : public TCPConnecter {
|
class NetworkContentConnecter : public TCPConnecter {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -63,18 +63,18 @@ struct ContentCallback {
|
||||||
class ClientNetworkContentSocketHandler : public NetworkContentSocketHandler, ContentCallback, HTTPCallback {
|
class ClientNetworkContentSocketHandler : public NetworkContentSocketHandler, ContentCallback, HTTPCallback {
|
||||||
protected:
|
protected:
|
||||||
using ContentIDList = std::vector<ContentID>; ///< List of content IDs to (possibly) select.
|
using ContentIDList = std::vector<ContentID>; ///< List of content IDs to (possibly) select.
|
||||||
std::vector<ContentCallback *> callbacks; ///< Callbacks to notify "the world"
|
std::vector<ContentCallback *> callbacks; ///< Callbacks to notify "the world"
|
||||||
ContentIDList requested; ///< ContentIDs we already requested (so we don't do it again)
|
ContentIDList requested; ///< ContentIDs we already requested (so we don't do it again)
|
||||||
ContentVector infos; ///< All content info we received
|
ContentVector infos; ///< All content info we received
|
||||||
std::unordered_multimap<ContentID, ContentID> reverse_dependency_map; ///< Content reverse dependency map
|
std::unordered_multimap<ContentID, ContentID> reverse_dependency_map; ///< Content reverse dependency map
|
||||||
std::vector<char> http_response; ///< The HTTP response to the requests we've been doing
|
std::vector<char> http_response; ///< The HTTP response to the requests we've been doing
|
||||||
int http_response_index; ///< Where we are, in the response, with handling it
|
int http_response_index = -2; ///< Where we are, in the response, with handling it
|
||||||
|
|
||||||
std::optional<FileHandle> cur_file; ///< Currently downloaded file
|
std::optional<FileHandle> cur_file; ///< Currently downloaded file
|
||||||
std::unique_ptr<ContentInfo> cur_info; ///< Information about the currently downloaded file
|
std::unique_ptr<ContentInfo> cur_info; ///< Information about the currently downloaded file
|
||||||
bool is_connecting; ///< Whether we're connecting
|
bool is_connecting = false; ///< Whether we're connecting
|
||||||
bool is_cancelled; ///< Whether the download has been cancelled
|
bool is_cancelled = false; ///< Whether the download has been cancelled
|
||||||
std::chrono::steady_clock::time_point last_activity; ///< The last time there was network activity
|
std::chrono::steady_clock::time_point last_activity = std::chrono::steady_clock::now(); ///< The last time there was network activity
|
||||||
|
|
||||||
friend class NetworkContentConnecter;
|
friend class NetworkContentConnecter;
|
||||||
|
|
||||||
|
@ -103,9 +103,6 @@ public:
|
||||||
/** The idle timeout; when to close the connection because it's idle. */
|
/** The idle timeout; when to close the connection because it's idle. */
|
||||||
static constexpr std::chrono::seconds IDLE_TIMEOUT = std::chrono::seconds(60);
|
static constexpr std::chrono::seconds IDLE_TIMEOUT = std::chrono::seconds(60);
|
||||||
|
|
||||||
ClientNetworkContentSocketHandler();
|
|
||||||
~ClientNetworkContentSocketHandler();
|
|
||||||
|
|
||||||
void Connect();
|
void Connect();
|
||||||
void SendReceive();
|
void SendReceive();
|
||||||
NetworkRecvStatus CloseConnection(bool error = true) override;
|
NetworkRecvStatus CloseConnection(bool error = true) override;
|
||||||
|
|
Loading…
Reference in New Issue