Gin
|
Downloads files to a memory block and then calls a lambda on the message thread with the results. More...
Classes | |
struct | DownloadResult |
Public Member Functions | |
DownloadManager (int connectTimeout=30 *1000, int shutdownTimeout=30 *1000) | |
~DownloadManager () | |
void | setQueueFinishedCallback (std::function< void()> callback) |
This callback is called every time all downloads are finished. More... | |
void | setConnectTimeout (int timeout) |
How long connecting is given before it times out. More... | |
void | setRetryLimit (int limit) |
If a download fails, how long many times it should retry. More... | |
void | setRetryDelay (double seconds) |
If a download fails, how long to wait until trying again. More... | |
void | setConcurrentDownloadLimit (int l) |
Maximum number of downloads to allow at once. More... | |
int | getNumberOfDownloads () |
Number of items in download queue. More... | |
void | setThreadPriority (juce::Thread::Priority p) |
Set download thread priority. More... | |
void | setProgressInterval (int ms) |
Sets minimum time between download progress callbacks in milliseconds. More... | |
void | setDownloadBlockSize (int bs) |
Sets the block size of chunks to download. More... | |
int | getNumDownloadsInQueue () |
void | enableGzipDeflate (bool e) |
If enabled, will request the server sends the data compressed This only has effect on windows. More... | |
void | pauseDownloads (bool) |
Pause / resume all downloads. More... | |
int | startAsyncDownload (juce::String url, juce::String postData, std::function< void(DownloadResult)> completionCallback, std::function< void(juce::int64, juce::int64, juce::int64)> progressCallback=nullptr, juce::String extraHeaders={}) |
Starts a download and returns the download id which can be used to cancel the download. More... | |
int | startAsyncDownload (juce::URL url, std::function< void(DownloadResult)> completionCallback, std::function< void(juce::int64, juce::int64, juce::int64)> progressCallback=nullptr, juce::String extraHeaders={}) |
void | cancelAllDownloads () |
Cancels all downloads. More... | |
void | cancelDownload (int downloadId) |
Cancels a download with a given id. More... | |
DownloadResult | blockingDownload (juce::String url, juce::String postData, juce::String extraHeaders={}) |
DownloadResult | blockingDownload (juce::URL url, juce::String extraHeaders={}) |
Downloads files to a memory block and then calls a lambda on the message thread with the results.
Does not block the message thread while establishing the HTTP connect like URL::downloadToFile
DownloadManager::DownloadManager | ( | int | connectTimeout = 30 *1000 , |
int | shutdownTimeout = 30 *1000 |
||
) |
DownloadManager::~DownloadManager | ( | ) |
void DownloadManager::setQueueFinishedCallback | ( | std::function< void()> | callback | ) |
This callback is called every time all downloads are finished.
void DownloadManager::setConnectTimeout | ( | int | timeout | ) |
How long connecting is given before it times out.
void DownloadManager::setRetryLimit | ( | int | limit | ) |
If a download fails, how long many times it should retry.
void DownloadManager::setRetryDelay | ( | double | seconds | ) |
If a download fails, how long to wait until trying again.
void DownloadManager::setConcurrentDownloadLimit | ( | int | l | ) |
Maximum number of downloads to allow at once.
int DownloadManager::getNumberOfDownloads | ( | ) |
Number of items in download queue.
void DownloadManager::setThreadPriority | ( | juce::Thread::Priority | p | ) |
Set download thread priority.
Does not affect priority of already running threads
void DownloadManager::setProgressInterval | ( | int | ms | ) |
Sets minimum time between download progress callbacks in milliseconds.
References math::max().
void DownloadManager::setDownloadBlockSize | ( | int | bs | ) |
Sets the block size of chunks to download.
Progress callbacks and cancelling downloads can only happen between these blocks. Max size is 128 KB
int DownloadManager::getNumDownloadsInQueue | ( | ) |
void DownloadManager::enableGzipDeflate | ( | bool | e | ) |
If enabled, will request the server sends the data compressed This only has effect on windows.
On macOS it is handled by the system libraries and is always on.
void DownloadManager::pauseDownloads | ( | bool | ) |
Pause / resume all downloads.
This actually stops any running downloads and then restarts them when unpaused. You will loose some downloaded data that will need to be redownloaded.
int DownloadManager::startAsyncDownload | ( | juce::String | url, |
juce::String | postData, | ||
std::function< void(DownloadResult)> | completionCallback, | ||
std::function< void(juce::int64, juce::int64, juce::int64)> | progressCallback = nullptr , |
||
juce::String | extraHeaders = {} |
||
) |
Starts a download and returns the download id which can be used to cancel the download.
progressCallback returns current amount downloaded, total amount to download, and amount downloaded since last callback. Note that for http chunk encoding total size is unknown and will be maximum int64 value.
int DownloadManager::startAsyncDownload | ( | juce::URL | url, |
std::function< void(DownloadResult)> | completionCallback, | ||
std::function< void(juce::int64, juce::int64, juce::int64)> | progressCallback = nullptr , |
||
juce::String | extraHeaders = {} |
||
) |
void DownloadManager::cancelAllDownloads | ( | ) |
Cancels all downloads.
void DownloadManager::cancelDownload | ( | int | downloadId | ) |
Cancels a download with a given id.
DownloadResult DownloadManager::blockingDownload | ( | juce::String | url, |
juce::String | postData, | ||
juce::String | extraHeaders = {} |
||
) |
DownloadResult DownloadManager::blockingDownload | ( | juce::URL | url, |
juce::String | extraHeaders = {} |
||
) |