10 #ifndef NETWORK_CONTENT_H 11 #define NETWORK_CONTENT_H 81 bool Receive_SERVER_INFO(
Packet *p)
override;
82 bool Receive_SERVER_CONTENT(
Packet *p)
override;
94 void OnReceiveData(
const char *data,
size_t length)
override;
96 bool BeforeDownload();
99 void DownloadSelectedContentHTTP(
const ContentIDList &content);
100 void DownloadSelectedContentFallback(
const ContentIDList &content);
103 static const int IDLE_TIMEOUT = 60 * 1000;
110 void Close()
override;
113 void RequestContentList(uint count,
const ContentID *content_ids);
114 void RequestContentList(
ContentVector *cv,
bool send_md5sum =
true);
116 void DownloadSelectedContent(uint &files, uint &bytes,
bool fallback =
false);
121 void SelectUpgrade();
130 uint
Length()
const {
return (uint)this->infos.size(); }
Helper to mark the end of the types.
ContentVector infos
All content info we received.
const ContentInfo *const * ConstContentIterator
Iterator for the constant content vector.
ConstContentIterator Begin() const
Get the begin of the content inf iterator.
Basic functions to receive and send HTTP TCP packets.
Internal entity of a packet.
std::vector< char > http_response
The HTTP response to the requests we've been doing.
Socket handler for the content server connection.
Base socket handler for all Content TCP sockets.
std::vector< ContentCallback * > callbacks
Callbacks to notify "the world".
Callbacks for notifying others about incoming data.
ContentID
Unique identifier for the content.
bool isConnecting
Whether we're connecting.
void ShowMissingContentWindow(const GRFConfig *list)
Show the content list window with all missing grfs from the given list.
virtual void OnDisconnect()
Callback for when the connection got disconnected.
void AddCallback(ContentCallback *cb)
Add a callback to this class.
std::vector< ContentID > ContentIDList
List of content IDs to (possibly) select.
ConstContentIterator End() const
Get the end of the content inf iterator.
std::vector< ContentInfo * > ContentVector
Vector with content info.
Information about GRF, used in the game and (part of it) in savegames.
uint32 lastActivity
The last time there was network activity.
virtual void OnDownloadProgress(const ContentInfo *ci, int bytes)
We have progress in the download of a file.
ConstContentIterator Get(uint32 index) const
Get the nth position of the content inf iterator.
virtual ~ContentCallback()
Silentium.
ContentIDList requested
ContentIDs we already requested (so we don't do it again)
Connect to the content server.
Basic functions to receive and send TCP packets to/from the content server.
ContentInfo ** ContentIterator
Iterator for the content vector.
uint Length() const
Get the number of content items we know locally.
ContentType
The values in the enum are important; they are used as database 'keys'.
void RemoveCallback(ContentCallback *cb)
Remove a callback.
bool include(std::vector< T > &vec, const T &item)
Helper function to append an item to a vector if it is not already contained Consider using std::set...
void OnFailure() override
Callback for when the connection attempt failed.
Callback for when the HTTP handler has something to tell us.
virtual void OnReceiveContentInfo(const ContentInfo *ci)
We received a content info.
ContentInfo * curInfo
Information about the currently downloaded file.
virtual void OnConnect(bool success)
Callback for when the connection has finished.
int http_response_index
Where we are, in the response, with handling it.
virtual void OnDownloadComplete(ContentID cid)
We have finished downloading a file.
void Connect()
The actual connection function.
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
FILE * curFile
Currently downloaded file.
Container for all important information about a piece of content.
void ShowNetworkContentListWindow(ContentVector *cv=nullptr, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
std::vector< const ContentInfo * > ConstContentVector
Vector with constant content info.