A download helper class used for downloading assets off of web servers.
This class can be used to simplify the process of downloading image files or other asset types off of a web server. Before using this helper the CYIHTTPService must be started using CYIHTTPService::Start. The helper adds downloaded assets to the CYIAssetManager. When the helper receives a cached response from the HTTP service it will attempt to retreive an asset from the asset manager in order to reuse it.
#include <network/YiAssetDownloadHelper.h>

Public Types | |
| enum | DOWNLOAD_STATE { IDLE = CYIAbstractDownloadHelper::IDLE, DOWNLOADING = CYIAbstractDownloadHelper::DOWNLOADING } |
| enum | FAILURE_TYPE { INVALID_URL = CYIAbstractDownloadHelper::INVALID_URL, NETWORK_ERROR = CYIAbstractDownloadHelper::NETWORK_ERROR, INVALID_ASSET } |
Public Types inherited from CYIAbstractDownloadHelper | |
| enum | DOWNLOAD_STATE { IDLE = 0, DOWNLOADING } |
| enum | FAILURE_TYPE { INVALID_URL = 0, NETWORK_ERROR } |
Public Attributes | |
| CYISignal< const std::shared_ptr< CYIAsset > &, const CYIUrl & > | AssetReady |
| CYISignal< FAILURE_TYPE, const CYIUrl & > | AssetDownloadFailed |
| CYISignal< const CYIUrl & > | AssetDownloadCancelled |
Public Attributes inherited from CYIAbstractDownloadHelper | |
| CYISignal< FAILURE_TYPE, const CYIUrl & > | DownloadFailed |
| CYISignal< const CYIUrl & > | DownloadCancelled |
| CYISignal< const CYIUrl & > | DownloadComplete |
Protected Member Functions | |
| virtual void | OnRequestCompleted (const std::shared_ptr< CYIHTTPRequest > &pRequest, const std::shared_ptr< CYIHTTPResponse > &pResponse, bool bCachedResponse) override |
| virtual void | OnDecodeComplete (int32_t nJobID, std::shared_ptr< CYIAsset > pAsset, int32_t nLoadStatus, void *pListenerPrivate) override |
| virtual void | CancelDownloadImplementation () override |
Protected Member Functions inherited from CYIAbstractDownloadHelper | |
| virtual void | OnRequestFailed (const std::shared_ptr< CYIHTTPRequest > &pRequest) |
Additional Inherited Members | |
Protected Attributes inherited from CYIAbstractDownloadHelper | |
| DOWNLOAD_STATE | m_state |
| CYIUrl | m_url |
| std::shared_ptr< CYIHTTPRequest > | m_pCurrentRequest |
| std::shared_ptr< CYIHTTPResponse > | m_pCurrentResponse |
| CYIRecursiveMutex | m_stateMutex |
| CYIAssetDownloadHelper::CYIAssetDownloadHelper | ( | ) |
Constructs a default CYIAssetDownloadHelper.
| CYIAssetDownloadHelper::CYIAssetDownloadHelper | ( | const CYIUrl & | url | ) |
Constructs a CYIAssetDownloadHelper initialized with an asset url.
|
virtual |
|
overrideprotectedvirtual |
Called when a download is being cancelled. Subclasses can implement this method to perform specific functions when a download is cancelled.
Implements CYIAbstractDownloadHelper.
| DOWNLOAD_STATE CYIAssetDownloadHelper::GetDownloadState | ( | ) | const |
Returns the current download state of the helper.
|
overrideprotectedvirtual |
Called when the asset decoding completes. If successful the asset will be emitted in the CYIAssetDownloadHelper::AssetReady signal. If unsuccessful the CYIAssetDownloadHelper::AssetDownloadFailed signal will be emmited.
Implements CYIAssetLoader::DecodeListener.
|
overrideprotectedvirtual |
Called when the request has completed. Implementor should call the base class to register the CYIAssetDownloadHelper to be a CYIAssetLoader::DecodeListener, and start the asset's decoding using the CYIAssetLoader. If the asset can't be decoded the CYIAssetDownloadHelper::AssetDownloadFailed signal will be emitted.
Reimplemented from CYIAbstractDownloadHelper.
Signals that the asset download has been cancelled and provides the URL of the cancelled download.
| CYISignal<FAILURE_TYPE, const CYIUrl & > CYIAssetDownloadHelper::AssetDownloadFailed |
Signals that the asset download has failed and provides the URL which the asset download failure occured along with the cause of failure.
Signals that the asset download has completed.