You.i Engine
CYIRemoteAssetDownloadHelper Class Reference

Detailed Description

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. This helper will download and save undecoded asset data for later decoding.

This class is primarily used by the CYIRemoteAssetCatalog to download undecoded asset data and store it for later in-memory decoding. Other classes may make use of this helper if they require downloading data and not decoding it.

See also
CYIHTTPService

#include <network/YiRemoteAssetDownloadHelper.h>

Inheritance diagram for CYIRemoteAssetDownloadHelper:

Public Member Functions

 CYIRemoteAssetDownloadHelper ()
 
 CYIRemoteAssetDownloadHelper (const CYIUrl &url)
 
virtual ~CYIRemoteAssetDownloadHelper ()
 
void ClearData ()
 
const std::vector< uint8_t > & GetData () const
 
- Public Member Functions inherited from CYIAbstractDownloadHelper
 CYIAbstractDownloadHelper ()
 
 CYIAbstractDownloadHelper (const CYIUrl &url)
 
virtual ~CYIAbstractDownloadHelper ()
 
const CYIUrlGetUrl () const
 
void SetUrl (const CYIUrl &url)
 
void StartDownload ()
 
void StartDownload (const CYIUrl &url)
 
void CancelDownload ()
 
DOWNLOAD_STATE GetDownloadState () const
 
- Public Member Functions inherited from CYISignalHandler
 CYISignalHandler ()
 
 CYISignalHandler (const CYISignalHandler &rSignalHandler)
 
virtual ~CYISignalHandler ()
 
CYISignalHandleroperator= (const CYISignalHandler &rSignalHandler)
 
void MoveToThread (CYIThread *pThread)
 This function allows the user to override the default thread affinity to any CYIThread that may or may not be running. More...
 
CYIThreadHandle GetThreadAffinity () const
 
void SetThreadAffinity (const CYIThreadHandle &rThreadAffinity)
 
virtual bool IsConnected () const
 
virtual bool IsConnected (const CYISignalBase &rSignal) const
 
void Disconnect (CYISignalBase &rSignal)
 
void DisconnectFromAllSignals ()
 
- Public Member Functions inherited from CYIThread::Listener
 Listener ()
 
virtual ~Listener ()
 
virtual void OnThreadStarted (CYIThread *)
 
virtual void OnThreadTerminated (CYIThread *)
 
virtual void OnThreadFinished (CYIThread *)
 
- Public Member Functions inherited from CYIScriptableObject
 CYIScriptableObject ()
 
 CYIScriptableObject (const CYIScriptableObject &other)
 
CYIScriptableObjectoperator= (const CYIScriptableObject &other)
 
virtual ~CYIScriptableObject ()
 
CYIBindingImplementationGetBindingImplementation () const
 
void SetBindingImplementation (CYIBindingImplementation *pBindingImplementation)
 
virtual const CYIRuntimeTypeInfoGetRuntimeTypeInfoForScriptObject () const
 

Protected Member Functions

virtual void OnRequestCompleted (const std::shared_ptr< CYIHTTPRequest > &pRequest, const std::shared_ptr< CYIHTTPResponse > &pResponse, bool bCachedResponse) override
 
virtual void CancelDownloadImplementation () override
 
- Protected Member Functions inherited from CYIAbstractDownloadHelper
virtual void OnRequestFailed (const std::shared_ptr< CYIHTTPRequest > &pRequest)
 

Additional Inherited Members

- Public Types inherited from CYIAbstractDownloadHelper
enum  DOWNLOAD_STATE {
  IDLE = 0,
  DOWNLOADING
}
 
enum  FAILURE_TYPE {
  INVALID_URL = 0,
  NETWORK_ERROR
}
 
- Public Attributes inherited from CYIAbstractDownloadHelper
CYISignal< FAILURE_TYPE, const CYIUrl & > DownloadFailed
 
CYISignal< const CYIUrl & > DownloadCancelled
 
CYISignal< const CYIUrl & > DownloadComplete
 
- Protected Attributes inherited from CYIAbstractDownloadHelper
DOWNLOAD_STATE m_state
 
CYIUrl m_url
 
std::shared_ptr< CYIHTTPRequestm_pCurrentRequest
 
std::shared_ptr< CYIHTTPResponsem_pCurrentResponse
 
CYIRecursiveMutex m_stateMutex
 

Constructor & Destructor Documentation

CYIRemoteAssetDownloadHelper::CYIRemoteAssetDownloadHelper ( )

Constructs a default CYIRemoteAssetDownloadHelper.

Note
A url must be set using SetUrl before an asset download can be succesfully started.
CYIRemoteAssetDownloadHelper::CYIRemoteAssetDownloadHelper ( const CYIUrl url)

Constructs a CYIRemoteAssetDownloadHelper initialized with an asset url.

virtual CYIRemoteAssetDownloadHelper::~CYIRemoteAssetDownloadHelper ( )
virtual

Member Function Documentation

virtual void CYIRemoteAssetDownloadHelper::CancelDownloadImplementation ( )
overrideprotectedvirtual

Called when a download is being cancelled. Implementations can assume that m_stateMutex is locked and m_state is DOWNLOADING.

See also
CancelDownload

Implements CYIAbstractDownloadHelper.

void CYIRemoteAssetDownloadHelper::ClearData ( )

Clears the downloaded data from memory. This may be necessary as the amount of available memory decreases.

const std::vector<uint8_t>& CYIRemoteAssetDownloadHelper::GetData ( ) const

Returns the undecoded, downloaded data.

virtual void CYIRemoteAssetDownloadHelper::OnRequestCompleted ( const std::shared_ptr< CYIHTTPRequest > &  pRequest,
const std::shared_ptr< CYIHTTPResponse > &  pResponse,
bool  bCachedResponse 
)
overrideprotectedvirtual

Called when the request has completed. Implementations should call the base class to get and save the downloaded data.

Reimplemented from CYIAbstractDownloadHelper.


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