OpenTTD Source 20250513-master-gc718858999
ClientNetworkContentSocketHandler Class Reference

Socket handler for the content server connection. More...

#include <network_content.h>

Inheritance diagram for ClientNetworkContentSocketHandler:
NetworkContentSocketHandler ContentCallback HTTPCallback NetworkTCPSocketHandler NetworkSocketHandler

Public Member Functions

void Connect ()
 Connect with the content server.
 
void SendReceive ()
 Check whether we received/can send some data from/to the content server and when that's the case handle it appropriately.
 
NetworkRecvStatus CloseConnection (bool error=true) override
 Disconnect from the content server.
 
void Cancel ()
 Cancel the current download.
 
void RequestContentList (ContentType type)
 Request the content list for the given type.
 
void RequestContentList (std::span< const ContentID > content_ids)
 Request the content list for a given number of content IDs.
 
void RequestContentList (ContentVector *cv, bool send_md5sum=true)
 Request the content list for a list of content.
 
void DownloadSelectedContent (uint &files, uint &bytes, bool fallback=false)
 Actually begin downloading the content we selected.
 
void RequestQueuedContentInfo ()
 Send a content request for queued content info download.
 
void Select (ContentID cid)
 Select a specific content id.
 
void Unselect (ContentID cid)
 Unselect a specific content id.
 
void SelectAll ()
 Select everything we can select.
 
void SelectUpgrade ()
 Select everything that's an update for something we've got.
 
void UnselectAll ()
 Unselect everything that we've not downloaded so far.
 
void ToggleSelectedState (const ContentInfo &ci)
 Toggle the state of a content info and check its dependencies.
 
void ReverseLookupDependency (ConstContentVector &parents, const ContentInfo &child) const
 Reverse lookup the dependencies of (direct) parents over a given child.
 
void ReverseLookupTreeDependency (ConstContentVector &tree, const ContentInfo *child) const
 Reverse lookup the dependencies of all parents over a given child.
 
void CheckDependencyState (const ContentInfo &ci)
 Check the dependencies (recursively) of this content info.
 
auto Info () const
 Get a read-only view of content info for iterating externally.
 
void Clear ()
 Clear all downloaded content information.
 
void AddCallback (ContentCallback *cb)
 Add a callback to this class.
 
void RemoveCallback (ContentCallback *cb)
 Remove a callback.
 
- Public Member Functions inherited from NetworkContentSocketHandler
 NetworkContentSocketHandler (SOCKET s=INVALID_SOCKET)
 Create a new cs socket handler for a given cs.
 
virtual ~NetworkContentSocketHandler ()
 On destructing of this class, the socket needs to be closed.
 
bool ReceivePackets ()
 Receive a packet at TCP level.
 
- Public Member Functions inherited from NetworkTCPSocketHandler
bool IsConnected () const
 Whether this socket is currently bound to a socket.
 
void CloseSocket ()
 Close the actual socket of the connection.
 
virtual void SendPacket (std::unique_ptr< Packet > &&packet)
 This function puts the packet in the send-queue and it is send as soon as possible.
 
SendPacketsState SendPackets (bool closing_down=false)
 Sends all the buffered packets out for this client.
 
virtual std::unique_ptr< PacketReceivePacket ()
 Receives a packet for the given client.
 
bool CanSendReceive ()
 Check whether this socket can send or receive something.
 
bool HasSendQueue ()
 Whether there is something pending in the send queue.
 
 NetworkTCPSocketHandler (SOCKET s=INVALID_SOCKET)
 Construct a socket handler for a TCP connection.
 
- Public Member Functions inherited from NetworkSocketHandler
 NetworkSocketHandler ()=default
 Create a new unbound socket.
 
virtual ~NetworkSocketHandler ()=default
 Close the socket when destructing the socket handler.
 
void MarkClosed ()
 Mark the connection as closed.
 
bool HasClientQuit () const
 Whether the current client connected to the socket has quit.
 
void Reopen ()
 Reopen the socket so we can send/receive stuff again.
 

Static Public Attributes

static constexpr std::chrono::seconds IDLE_TIMEOUT = std::chrono::seconds(60)
 The idle timeout; when to close the connection because it's idle.
 

Protected Types

using ContentIDList = std::vector< ContentID >
 List of content IDs to (possibly) select.
 

Protected Member Functions

bool Receive_SERVER_INFO (Packet &p) override
 Server sending list of content info: uint8_t type (invalid ID == does not exist) uint32_t id uint32_t file_size string name (max 32 characters) string version (max 16 characters) uint32_t unique id uint8_t md5sum (16 bytes) uint8_t dependency count uint32_t unique id of dependency (dependency count times) uint8_t tag count string tag (max 32 characters for tag count times)
 
bool Receive_SERVER_CONTENT (Packet &p) override
 Server sending list of content info: uint32_t unique id uint32_t file size (0 == does not exist) string file name (max 48 characters) After this initial packet, packets with the actual data are send using the same packet type.
 
ContentInfoGetContent (ContentID cid) const
 Get the content info based on a ContentID.
 
void DownloadContentInfo (ContentID cid)
 Download information of a given Content ID if not already tried.
 
void OnConnect (bool success) override
 Callback for when the connection has finished.
 
void OnDisconnect () override
 Callback for when the connection got disconnected.
 
void OnReceiveContentInfo (const ContentInfo &ci) override
 We received a content info.
 
void OnDownloadProgress (const ContentInfo &ci, int bytes) override
 We have progress in the download of a file.
 
void OnDownloadComplete (ContentID cid) override
 We have finished downloading a file.
 
void OnFailure () override
 An error has occurred and the connection has been closed.
 
void OnReceiveData (std::unique_ptr< char[]> data, size_t length) override
 We're receiving data.
 
bool IsCancelled () const override
 Check if there is a request to cancel the transfer.
 
bool BeforeDownload ()
 Handle the opening of the file before downloading.
 
void AfterDownload ()
 Handle the closing and extracting of a file after downloading it has been done.
 
void DownloadSelectedContentHTTP (const ContentIDList &content)
 Initiate downloading the content over HTTP.
 
void DownloadSelectedContentFallback (const ContentIDList &content)
 Initiate downloading the content over the fallback protocol.
 
- Protected Member Functions inherited from NetworkContentSocketHandler
bool ReceiveInvalidPacket (PacketContentType type)
 Helper for logging receiving invalid packets.
 
virtual bool Receive_CLIENT_INFO_LIST (Packet &p)
 Client requesting a list of content info: uint8_t type uint32_t openttd version (or 0xFFFFFFFF if using a list) Only if the above value is 0xFFFFFFFF: uint8_t count string branch-name ("vanilla" for upstream OpenTTD) string release version (like "12.0")
 
virtual bool Receive_CLIENT_INFO_ID (Packet &p)
 Client requesting a list of content info: uint16_t count of ids uint32_t id (count times)
 
virtual bool Receive_CLIENT_INFO_EXTID (Packet &p)
 Client requesting a list of content info based on an external 'unique' id; GRF ID for NewGRFS, shortname and for base graphics and AIs.
 
virtual bool Receive_CLIENT_INFO_EXTID_MD5 (Packet &p)
 Client requesting a list of content info based on an external 'unique' id; GRF ID + MD5 checksum for NewGRFS, shortname and xor-ed MD5 checksums for base graphics and AIs.
 
virtual bool Receive_CLIENT_CONTENT (Packet &p)
 Client requesting the actual content: uint16_t count of unique ids uint32_t unique id (count times)
 
bool HandlePacket (Packet &p)
 Handle the given packet, i.e.
 

Protected Attributes

std::vector< ContentCallback * > callbacks
 Callbacks to notify "the world".
 
ContentIDList requested
 ContentIDs we already requested (so we don't do it again)
 
ContentIDList queued
 ContentID queue to be requested.
 
ContentVector infos
 All content info we received.
 
std::unordered_multimap< ContentID, ContentIDreverse_dependency_map
 Content reverse dependency map.
 
std::vector< char > http_response
 The HTTP response to the requests we've been doing.
 
int http_response_index = -2
 Where we are, in the response, with handling it.
 
std::optional< FileHandlecur_file
 Currently downloaded file.
 
std::unique_ptr< ContentInfocur_info
 Information about the currently downloaded file.
 
bool is_connecting = false
 Whether we're connecting.
 
bool is_cancelled = false
 Whether the download has been cancelled.
 
std::chrono::steady_clock::time_point last_activity = std::chrono::steady_clock::now()
 The last time there was network activity.
 
- Protected Attributes inherited from NetworkSocketHandler
std::unique_ptr< class NetworkEncryptionHandlerreceive_encryption_handler = nullptr
 The handler for decrypting received packets.
 
std::unique_ptr< class NetworkEncryptionHandlersend_encryption_handler = nullptr
 The handler for encrypting sent packets.
 

Friends

class NetworkContentConnecter
 

Additional Inherited Members

- Data Fields inherited from NetworkTCPSocketHandler
SOCKET sock = INVALID_SOCKET
 The socket currently connected to.
 
bool writable = false
 Can we write to this socket?
 
- Private Member Functions inherited from ContentCallback
virtual ~ContentCallback ()=default
 Silentium.
 
- Private Member Functions inherited from HTTPCallback
virtual ~HTTPCallback ()=default
 Silentium.
 

Detailed Description

Socket handler for the content server connection.

Definition at line 63 of file network_content.h.

Member Typedef Documentation

◆ ContentIDList

List of content IDs to (possibly) select.

Definition at line 65 of file network_content.h.

Member Function Documentation

◆ AddCallback()

void ClientNetworkContentSocketHandler::AddCallback ( ContentCallback cb)
inline

◆ AfterDownload()

void ClientNetworkContentSocketHandler::AfterDownload ( )
protected

◆ BeforeDownload()

bool ClientNetworkContentSocketHandler::BeforeDownload ( )
protected

Handle the opening of the file before downloading.

Returns
false on any error.

Definition at line 494 of file network_content.cpp.

References CloseWindowById(), cur_info, GetEncodedString(), GetFullFilename(), FileHandle::Open(), ShowErrorMessage(), WC_NETWORK_STATUS_WINDOW, WL_ERROR, and WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD.

Referenced by OnReceiveData(), and Receive_SERVER_CONTENT().

◆ Cancel()

void ClientNetworkContentSocketHandler::Cancel ( void  )

Cancel the current download.

Definition at line 751 of file network_content.cpp.

References CloseConnection(), and is_cancelled.

Referenced by NetworkContentDownloadStatusWindow::OnClick().

◆ CheckDependencyState()

void ClientNetworkContentSocketHandler::CheckDependencyState ( const ContentInfo ci)

◆ Clear()

void ClientNetworkContentSocketHandler::Clear ( )

Clear all downloaded content information.

Definition at line 1044 of file network_content.cpp.

References infos, queued, requested, and reverse_dependency_map.

Referenced by ShowNetworkContentListWindow().

◆ CloseConnection()

NetworkRecvStatus ClientNetworkContentSocketHandler::CloseConnection ( bool  error = true)
overridevirtual

◆ Connect()

void ClientNetworkContentSocketHandler::Connect ( )

◆ DownloadContentInfo()

void ClientNetworkContentSocketHandler::DownloadContentInfo ( ContentID  cid)
protected

Download information of a given Content ID if not already tried.

Parameters
cidthe ID to try

Definition at line 792 of file network_content.cpp.

References queued, requested, and TimeoutTimer< TTimerType >::Reset().

Referenced by CheckDependencyState().

◆ DownloadSelectedContent()

void ClientNetworkContentSocketHandler::DownloadSelectedContent ( uint &  files,
uint &  bytes,
bool  fallback = false 
)

Actually begin downloading the content we selected.

Parameters
[out]filesThe number of files we are going to download.
[out]bytesThe number of bytes we are going to download.
fallbackWhether to use the fallback or not.

Definition at line 292 of file network_content.cpp.

References ContentInfo::ALREADY_HERE, DownloadSelectedContentFallback(), DownloadSelectedContentHTTP(), infos, and is_cancelled.

Referenced by BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(), and OnFailure().

◆ DownloadSelectedContentFallback()

void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback ( const ContentIDList content)
protected

Initiate downloading the content over the fallback protocol.

Parameters
contentThe content to download.

Definition at line 338 of file network_content.cpp.

References Connect(), PACKET_CONTENT_CLIENT_CONTENT, NetworkTCPSocketHandler::SendPacket(), and TCP_MTU.

Referenced by DownloadSelectedContent().

◆ DownloadSelectedContentHTTP()

void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP ( const ContentIDList content)
protected

Initiate downloading the content over HTTP.

Parameters
contentThe content to download.

Definition at line 322 of file network_content.cpp.

References NetworkHTTPSocketHandler::Connect(), http_response_index, and NetworkContentMirrorUriString().

Referenced by DownloadSelectedContent().

◆ GetContent()

ContentInfo * ClientNetworkContentSocketHandler::GetContent ( ContentID  cid) const
protected

Get the content info based on a ContentID.

Parameters
cidthe ContentID to search for
Returns
the ContentInfo or nullptr if not found

Definition at line 832 of file network_content.cpp.

References infos.

Referenced by CheckDependencyState(), OnDownloadComplete(), ReverseLookupDependency(), Select(), and Unselect().

◆ Info()

auto ClientNetworkContentSocketHandler::Info ( ) const
inline

Get a read-only view of content info for iterating externally.

Returns
Read-only view of content info.

Definition at line 134 of file network_content.h.

Referenced by NetworkContentListWindow::BuildContentList(), and NetworkContentListWindow::DrawDetails().

◆ IsCancelled()

bool ClientNetworkContentSocketHandler::IsCancelled ( ) const
overrideprotectedvirtual

Check if there is a request to cancel the transfer.

Returns
true iff the connection is cancelled.
Note
Cancellations are never instant, and can take a bit of time to be processed. The object needs to remain valid until the OnFailure() callback is called.

Implements HTTPCallback.

Definition at line 553 of file network_content.cpp.

References is_cancelled.

◆ OnConnect()

void ClientNetworkContentSocketHandler::OnConnect ( bool  success)
overrideprotectedvirtual

Callback for when the connection has finished.

Parameters
successwhether the connection was made or that we failed to make it

Reimplemented from ContentCallback.

Definition at line 1054 of file network_content.cpp.

References callbacks, and ContentCallback::OnConnect().

Referenced by NetworkContentConnecter::OnConnect(), and NetworkContentConnecter::OnFailure().

◆ OnDisconnect()

void ClientNetworkContentSocketHandler::OnDisconnect ( )
overrideprotectedvirtual

Callback for when the connection got disconnected.

Reimplemented from ContentCallback.

Definition at line 1064 of file network_content.cpp.

References callbacks, and ContentCallback::OnDisconnect().

Referenced by CloseConnection().

◆ OnDownloadComplete()

void ClientNetworkContentSocketHandler::OnDownloadComplete ( ContentID  cid)
overrideprotectedvirtual

We have finished downloading a file.

Parameters
cidthe ContentID of the downloaded file

Reimplemented from ContentCallback.

Definition at line 1092 of file network_content.cpp.

References ContentInfo::ALREADY_HERE, callbacks, GetContent(), ContentCallback::OnDownloadComplete(), and ContentInfo::state.

Referenced by AfterDownload().

◆ OnDownloadProgress()

void ClientNetworkContentSocketHandler::OnDownloadProgress ( const ContentInfo ci,
int  bytes 
)
overrideprotectedvirtual

We have progress in the download of a file.

Parameters
cithe content info of the file
bytesthe number of bytes downloaded since the previous call

Reimplemented from ContentCallback.

Definition at line 1083 of file network_content.cpp.

References callbacks, and ContentCallback::OnDownloadProgress().

Referenced by OnFailure(), OnReceiveData(), and Receive_SERVER_CONTENT().

◆ OnFailure()

void ClientNetworkContentSocketHandler::OnFailure ( )
overrideprotectedvirtual

An error has occurred and the connection has been closed.

Note
HTTP socket handler is closed/freed.

Implements HTTPCallback.

Definition at line 559 of file network_content.cpp.

References cur_file, cur_info, DownloadSelectedContent(), http_response, http_response_index, is_cancelled, and OnDownloadProgress().

Referenced by OnReceiveData().

◆ OnReceiveContentInfo()

void ClientNetworkContentSocketHandler::OnReceiveContentInfo ( const ContentInfo ci)
overrideprotectedvirtual

We received a content info.

Parameters
cithe content info

Reimplemented from ContentCallback.

Definition at line 1073 of file network_content.cpp.

References callbacks, and ContentCallback::OnReceiveContentInfo().

Referenced by Receive_SERVER_INFO().

◆ OnReceiveData()

void ClientNetworkContentSocketHandler::OnReceiveData ( std::unique_ptr< char[]>  data,
size_t  length 
)
overrideprotectedvirtual

We're receiving data.

Parameters
datathe received data, nullptr when all data has been received.
lengththe amount of received data, 0 when all data has been received.
Note
When nullptr is sent the HTTP socket handler is closed/freed.

Implements HTTPCallback.

Definition at line 579 of file network_content.cpp.

References AfterDownload(), BeforeDownload(), NetworkHTTPSocketHandler::Connect(), cur_file, cur_info, http_response, http_response_index, StringConsumer::KEEP_SEPARATOR, OnDownloadProgress(), OnFailure(), and StringConsumer::ReadIntegerBase().

◆ Receive_SERVER_CONTENT()

bool ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT ( Packet p)
overrideprotectedvirtual

Server sending list of content info: uint32_t unique id uint32_t file size (0 == does not exist) string file name (max 48 characters) After this initial packet, packets with the actual data are send using the same packet type.

Parameters
pThe packet that was just received.
Returns
True upon success, otherwise false.

Reimplemented from NetworkContentSocketHandler.

Definition at line 450 of file network_content.cpp.

References AfterDownload(), BeforeDownload(), CloseConnection(), CloseWindowById(), cur_file, cur_info, GetEncodedString(), NETWORK_CONTENT_FILENAME_LENGTH, OnDownloadProgress(), Packet::Recv_string(), Packet::Recv_uint32(), Packet::Recv_uint8(), Packet::RemainingBytesToTransfer(), ShowErrorMessage(), Packet::TransferOut(), WC_NETWORK_STATUS_WINDOW, WL_ERROR, and WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD.

◆ Receive_SERVER_INFO()

bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO ( Packet p)
overrideprotectedvirtual

Server sending list of content info: uint8_t type (invalid ID == does not exist) uint32_t id uint32_t file_size string name (max 32 characters) string version (max 16 characters) uint32_t unique id uint8_t md5sum (16 bytes) uint8_t dependency count uint32_t unique id of dependency (dependency count times) uint8_t tag count string tag (max 32 characters for tag count times)

Parameters
pThe packet that was just received.
Returns
True upon success, otherwise false.

Reimplemented from NetworkContentSocketHandler.

Definition at line 86 of file network_content.cpp.

References AllowNewline, ContentInfo::ALREADY_HERE, CheckDependencyState(), CloseConnection(), ContentInfo::DOES_NOT_EXIST, GetHasContentProcforContentType(), infos, NETWORK_CONTENT_DESC_LENGTH, NETWORK_CONTENT_NAME_LENGTH, NETWORK_CONTENT_TAG_LENGTH, NETWORK_CONTENT_URL_LENGTH, NETWORK_CONTENT_VERSION_LENGTH, OnReceiveContentInfo(), Packet::Recv_bytes(), Packet::Recv_string(), Packet::Recv_uint32(), Packet::Recv_uint8(), ReplaceWithQuestionMark, reverse_dependency_map, ReverseLookupTreeDependency(), and ContentInfo::UNSELECTED.

◆ RemoveCallback()

void ClientNetworkContentSocketHandler::RemoveCallback ( ContentCallback cb)
inline

◆ RequestContentList() [1/3]

◆ RequestContentList() [2/3]

void ClientNetworkContentSocketHandler::RequestContentList ( ContentVector cv,
bool  send_md5sum = true 
)

Request the content list for a list of content.

Parameters
cvList with unique IDs and MD5 checksums.
send_md5sumWhether we want a MD5 checksum matched set of files or not.

Definition at line 249 of file network_content.cpp.

References Connect(), infos, PACKET_CONTENT_CLIENT_INFO_EXTID, PACKET_CONTENT_CLIENT_INFO_EXTID_MD5, NetworkTCPSocketHandler::SendPacket(), and TCP_MTU.

◆ RequestContentList() [3/3]

void ClientNetworkContentSocketHandler::RequestContentList ( std::span< const ContentID content_ids)

Request the content list for a given number of content IDs.

Parameters
countThe number of IDs to request.
content_idsThe unique identifiers of the content to request information about.

Definition at line 218 of file network_content.cpp.

References Connect(), PACKET_CONTENT_CLIENT_INFO_ID, NetworkTCPSocketHandler::SendPacket(), and TCP_MTU.

◆ RequestQueuedContentInfo()

void ClientNetworkContentSocketHandler::RequestQueuedContentInfo ( )

Send a content request for queued content info download.

Definition at line 805 of file network_content.cpp.

References CONTENT_QUEUE_TIMEOUT, ContentInfo::id, infos, last_activity, queued, RequestContentList(), and TimeoutTimer< TTimerType >::Reset().

◆ ReverseLookupDependency()

void ClientNetworkContentSocketHandler::ReverseLookupDependency ( ConstContentVector parents,
const ContentInfo child 
) const

Reverse lookup the dependencies of (direct) parents over a given child.

Parameters
parentslist to store all parents in (is not cleared)
childthe child to search the parents' dependencies for

Definition at line 920 of file network_content.cpp.

References GetContent(), ContentInfo::id, and reverse_dependency_map.

Referenced by CheckDependencyState(), and ReverseLookupTreeDependency().

◆ ReverseLookupTreeDependency()

void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency ( ConstContentVector tree,
const ContentInfo child 
) const

Reverse lookup the dependencies of all parents over a given child.

Parameters
treelist to store all parents in (is not cleared)
childthe child to search the parents' dependencies for

Definition at line 934 of file network_content.cpp.

References include(), and ReverseLookupDependency().

Referenced by CheckDependencyState(), NetworkContentListWindow::DrawDetails(), and Receive_SERVER_INFO().

◆ Select()

void ClientNetworkContentSocketHandler::Select ( ContentID  cid)

Select a specific content id.

Parameters
cidthe content ID to select

Definition at line 845 of file network_content.cpp.

References CheckDependencyState(), GetContent(), ContentInfo::SELECTED, ContentInfo::state, and ContentInfo::UNSELECTED.

Referenced by BootstrapAskForDownloadWindow::OnReceiveContentInfo(), and ToggleSelectedState().

◆ SelectAll()

void ClientNetworkContentSocketHandler::SelectAll ( )

Select everything we can select.

Definition at line 868 of file network_content.cpp.

References CheckDependencyState(), infos, ContentInfo::SELECTED, and ContentInfo::UNSELECTED.

Referenced by NetworkContentListWindow::OnClick().

◆ SelectUpgrade()

void ClientNetworkContentSocketHandler::SelectUpgrade ( )

Select everything that's an update for something we've got.

Definition at line 879 of file network_content.cpp.

References CheckDependencyState(), infos, ContentInfo::SELECTED, and ContentInfo::UNSELECTED.

Referenced by NetworkContentListWindow::OnClick().

◆ SendReceive()

void ClientNetworkContentSocketHandler::SendReceive ( )

Check whether we received/can send some data from/to the content server and when that's the case handle it appropriately.

Definition at line 761 of file network_content.cpp.

References NetworkTCPSocketHandler::CanSendReceive(), CloseConnection(), IDLE_TIMEOUT, is_connecting, last_activity, NetworkContentSocketHandler::ReceivePackets(), NetworkTCPSocketHandler::SendPackets(), and NetworkTCPSocketHandler::sock.

Referenced by NetworkBackgroundLoop().

◆ ToggleSelectedState()

void ClientNetworkContentSocketHandler::ToggleSelectedState ( const ContentInfo ci)

◆ Unselect()

void ClientNetworkContentSocketHandler::Unselect ( ContentID  cid)

Unselect a specific content id.

Parameters
cidthe content ID to deselect

Definition at line 858 of file network_content.cpp.

References CheckDependencyState(), GetContent(), ContentInfo::IsSelected(), ContentInfo::state, and ContentInfo::UNSELECTED.

Referenced by CheckDependencyState(), and ToggleSelectedState().

◆ UnselectAll()

void ClientNetworkContentSocketHandler::UnselectAll ( )

Unselect everything that we've not downloaded so far.

Definition at line 890 of file network_content.cpp.

References ContentInfo::ALREADY_HERE, infos, and ContentInfo::UNSELECTED.

Referenced by NetworkContentListWindow::OnClick().

Friends And Related Symbol Documentation

◆ NetworkContentConnecter

friend class NetworkContentConnecter
friend

Definition at line 80 of file network_content.h.

Field Documentation

◆ callbacks

std::vector<ContentCallback *> ClientNetworkContentSocketHandler::callbacks
protected

Callbacks to notify "the world".

Definition at line 66 of file network_content.h.

Referenced by OnConnect(), OnDisconnect(), OnDownloadComplete(), OnDownloadProgress(), and OnReceiveContentInfo().

◆ cur_file

std::optional<FileHandle> ClientNetworkContentSocketHandler::cur_file
protected

Currently downloaded file.

Definition at line 74 of file network_content.h.

Referenced by AfterDownload(), OnFailure(), OnReceiveData(), and Receive_SERVER_CONTENT().

◆ cur_info

std::unique_ptr<ContentInfo> ClientNetworkContentSocketHandler::cur_info
protected

Information about the currently downloaded file.

Definition at line 75 of file network_content.h.

Referenced by AfterDownload(), BeforeDownload(), OnFailure(), OnReceiveData(), and Receive_SERVER_CONTENT().

◆ http_response

std::vector<char> ClientNetworkContentSocketHandler::http_response
protected

The HTTP response to the requests we've been doing.

Definition at line 71 of file network_content.h.

Referenced by OnFailure(), and OnReceiveData().

◆ http_response_index

int ClientNetworkContentSocketHandler::http_response_index = -2
protected

Where we are, in the response, with handling it.

Definition at line 72 of file network_content.h.

Referenced by DownloadSelectedContentHTTP(), OnFailure(), and OnReceiveData().

◆ IDLE_TIMEOUT

constexpr std::chrono::seconds ClientNetworkContentSocketHandler::IDLE_TIMEOUT = std::chrono::seconds(60)
staticconstexpr

The idle timeout; when to close the connection because it's idle.

Definition at line 105 of file network_content.h.

Referenced by SendReceive().

◆ infos

ContentVector ClientNetworkContentSocketHandler::infos
protected

◆ is_cancelled

bool ClientNetworkContentSocketHandler::is_cancelled = false
protected

Whether the download has been cancelled.

Definition at line 77 of file network_content.h.

Referenced by Cancel(), Connect(), DownloadSelectedContent(), IsCancelled(), and OnFailure().

◆ is_connecting

bool ClientNetworkContentSocketHandler::is_connecting = false
protected

Whether we're connecting.

Definition at line 76 of file network_content.h.

Referenced by Connect(), NetworkContentConnecter::OnConnect(), NetworkContentConnecter::OnFailure(), and SendReceive().

◆ last_activity

std::chrono::steady_clock::time_point ClientNetworkContentSocketHandler::last_activity = std::chrono::steady_clock::now()
protected

The last time there was network activity.

Definition at line 78 of file network_content.h.

Referenced by NetworkContentConnecter::OnConnect(), RequestQueuedContentInfo(), and SendReceive().

◆ queued

ContentIDList ClientNetworkContentSocketHandler::queued
protected

ContentID queue to be requested.

Definition at line 68 of file network_content.h.

Referenced by Clear(), DownloadContentInfo(), and RequestQueuedContentInfo().

◆ requested

ContentIDList ClientNetworkContentSocketHandler::requested
protected

ContentIDs we already requested (so we don't do it again)

Definition at line 67 of file network_content.h.

Referenced by Clear(), and DownloadContentInfo().

◆ reverse_dependency_map

std::unordered_multimap<ContentID, ContentID> ClientNetworkContentSocketHandler::reverse_dependency_map
protected

Content reverse dependency map.

Definition at line 70 of file network_content.h.

Referenced by Clear(), Receive_SERVER_INFO(), and ReverseLookupDependency().


The documentation for this class was generated from the following files: