cocos2d-x  3.3rc0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Downloader Class Reference

#include <Downloader.h>

Inheritance diagram for Downloader:

Classes

struct  DownloadUnit
 
struct  Error
 
struct  FileDescriptor
 
struct  ProgressData
 
struct  StreamData
 

Public Types

enum  ErrorCode {
  CREATE_FILE, NETWORK, NO_NEW_VERSION, UNCOMPRESS,
  CURL_UNINIT, CURL_MULTI_ERROR, CURL_EASY_ERROR, INVALID_URL,
  INVALID_STORAGE_PATH
}
 
typedef std::unordered_map
< std::string, DownloadUnit
DownloadUnits
typedef std::function< void(const
Downloader::Error &)> 
ErrorCallback
typedef std::function< void(double,
double, const std::string
&, const std::string &)> 
ProgressCallback
typedef std::function< void(const
std::string &, const
std::string &, const
std::string &)> 
SuccessCallback

Public Member Functions

int getConnectionTimeout ()
void setConnectionTimeout (int timeout)
void setErrorCallback (const ErrorCallback &callback)
var setErrorCallback ( var callback)
local setErrorCallback ( local callback)
void setProgressCallback (const ProgressCallback &callback)
void setSuccessCallback (const SuccessCallback &callback)
ErrorCallback getErrorCallback () const
ProgressCallback getProgressCallback () const
var getProgressCallback ()
SuccessCallback getSuccessCallback () const
var getSuccessCallback ()
local getSuccessCallback ()
long getContentSize (const std::string &srcUrl) const
void downloadToBufferAsync (const std::string &srcUrl, unsigned char *buffer, const long &size, const std::string &customId="")
void downloadToBufferSync (const std::string &srcUrl, unsigned char *buffer, const long &size, const std::string &customId="")
var downloadToBufferSync ( var srcUrl, var buffer, var size)
local downloadToBufferSync ( local srcUrl, local buffer, local size)
void downloadAsync (const std::string &srcUrl, const std::string &storagePath, const std::string &customId="")
void downloadSync (const std::string &srcUrl, const std::string &storagePath, const std::string &customId="")
void batchDownloadAsync (const DownloadUnits &units, const std::string &batchId="")
void batchDownloadSync (const DownloadUnits &units, const std::string &batchId="")
 Downloader ()
 The default constructor. More...
 
 ~Downloader ()

Protected Member Functions

void prepareDownload (const std::string &srcUrl, const std::string &storagePath, const std::string &customId, bool resumeDownload, FileDescriptor *fDesc, ProgressData *pData)
var prepareDownload ( var srcUrl, var storagePath, var customId, var resumeDownload, var fDesc, var pData)
local prepareDownload ( local srcUrl, local storagePath, local customId, local resumeDownload, local fDesc, local pData)
bool prepareHeader (void *curl, const std::string &srcUrl) const
var prepareHeader ( var curl, var srcUrl)
local prepareHeader ( local curl, local srcUrl)
void downloadToBuffer (const std::string &srcUrl, const std::string &customId, const StreamData &buffer, const ProgressData &data)
var downloadToBuffer ( var srcUrl, var customId, var buffer, var data)
local downloadToBuffer ( local srcUrl, local customId, local buffer, local data)
void download (const std::string &srcUrl, const std::string &customId, const FileDescriptor &fDesc, const ProgressData &data)
void groupBatchDownload (const DownloadUnits &units)
void notifyError (ErrorCode code, const std::string &msg="", const std::string &customId="", int curle_code=0, int curlm_code=0)
var notifyError ( var code, var 0, var 0)
local notifyError ( local code, local 0, local 0)
void notifyError (const std::string &msg, int curlm_code, const std::string &customId="")
void notifyError (const std::string &msg, const std::string &customId, int curle_code)

Friends

class AssetsManagerEx

Member Typedef Documentation

typedef std::unordered_map
<std::string, DownloadUnit>
DownloadUnits
typedef std::function<void(const
Downloader::Error &)>
ErrorCallback
typedef std::function<void(double,
double, const std::string
&, const std::string &)>
ProgressCallback
typedef std::function<void(const
std::string &, const
std::string &, const
std::string &)>
SuccessCallback

Member Enumeration Documentation

enum ErrorCode
strong
Enumerator
CREATE_FILE 
NETWORK 
NO_NEW_VERSION 
UNCOMPRESS 
CURL_UNINIT 
CURL_MULTI_ERROR 
CURL_EASY_ERROR 
INVALID_URL 
INVALID_STORAGE_PATH 
var ErrorCode
strong
Enumerator
CREATE_FILE 
NETWORK 
NO_NEW_VERSION 
UNCOMPRESS 
CURL_UNINIT 
CURL_MULTI_ERROR 
CURL_EASY_ERROR 
INVALID_URL 
INVALID_STORAGE_PATH 
local ErrorCode
strong
Enumerator
CREATE_FILE 
NETWORK 
NO_NEW_VERSION 
UNCOMPRESS 
CURL_UNINIT 
CURL_MULTI_ERROR 
CURL_EASY_ERROR 
INVALID_URL 
INVALID_STORAGE_PATH 

Constructor & Destructor Documentation

The default constructor.

var Downloader ( )

The default constructor.

local Downloader ( )

The default constructor.

~Downloader ( )
var ~Downloader ( )
local ~Downloader ( )

Member Function Documentation

void batchDownloadAsync ( const DownloadUnits units,
const std::string &  batchId = "" 
)
var batchDownloadAsync ( var  units,
var  batchId = "" 
)
local batchDownloadAsync ( local  units,
local  batchId = "" 
)
void batchDownloadSync ( const DownloadUnits units,
const std::string &  batchId = "" 
)
var batchDownloadSync ( var  units,
var  batchId = "" 
)
local batchDownloadSync ( local  units,
local  batchId = "" 
)
void download ( const std::string &  srcUrl,
const std::string &  customId,
const FileDescriptor fDesc,
const ProgressData data 
)
protected
var download ( var  srcUrl,
var  customId,
var  fDesc,
var  data 
)
protected
local download ( local  srcUrl,
local  customId,
local  fDesc,
local  data 
)
protected
void downloadAsync ( const std::string &  srcUrl,
const std::string &  storagePath,
const std::string &  customId = "" 
)
var downloadAsync ( var  srcUrl,
var  storagePath,
var  customId = "" 
)
local downloadAsync ( local  srcUrl,
local  storagePath,
local  customId = "" 
)
void downloadSync ( const std::string &  srcUrl,
const std::string &  storagePath,
const std::string &  customId = "" 
)
var downloadSync ( var  srcUrl,
var  storagePath,
var  customId = "" 
)
local downloadSync ( local  srcUrl,
local  storagePath,
local  customId = "" 
)
void downloadToBuffer ( const std::string &  srcUrl,
const std::string &  customId,
const StreamData buffer,
const ProgressData data 
)
protected
var downloadToBuffer ( var  srcUrl,
var  customId,
var  buffer,
var  data 
)
protected
local downloadToBuffer ( local  srcUrl,
local  customId,
local  buffer,
local  data 
)
protected
void downloadToBufferAsync ( const std::string &  srcUrl,
unsigned char *  buffer,
const long &  size,
const std::string &  customId = "" 
)
var downloadToBufferAsync ( var  srcUrl,
var  buffer,
var  size,
var  customId = "" 
)
local downloadToBufferAsync ( local  srcUrl,
local  buffer,
local  size,
local  customId = "" 
)
void downloadToBufferSync ( const std::string &  srcUrl,
unsigned char *  buffer,
const long &  size,
const std::string &  customId = "" 
)
var downloadToBufferSync ( var  srcUrl,
var  buffer,
var  size,
var  customId = "" 
)
local downloadToBufferSync ( local  srcUrl,
local  buffer,
local  size,
local  customId = "" 
)
int getConnectionTimeout ( )
var getConnectionTimeout ( )
local getConnectionTimeout ( )
long getContentSize ( const std::string &  srcUrl) const
var getContentSize ( var  srcUrl)
local getContentSize ( local  srcUrl)
ErrorCallback getErrorCallback ( ) const
inline
var getErrorCallback ( )
inline
local getErrorCallback ( )
inline
ProgressCallback
getProgressCallback
( ) const
inline
var getProgressCallback ( )
inline
local getProgressCallback ( )
inline
SuccessCallback getSuccessCallback ( ) const
inline
var getSuccessCallback ( )
inline
local getSuccessCallback ( )
inline
void groupBatchDownload ( const DownloadUnits units)
protected
var groupBatchDownload ( var  units)
protected
local groupBatchDownload ( local  units)
protected
void notifyError ( ErrorCode  code,
const std::string &  msg = "",
const std::string &  customId = "",
int  curle_code = 0,
int  curlm_code = 0 
)
protected
var notifyError ( var  code,
var  msg = "",
var  customId = "",
var  curle_code = 0,
var  curlm_code = 0 
)
protected
local notifyError ( local  code,
local  msg = "",
local  customId = "",
local  curle_code = 0,
local  curlm_code = 0 
)
protected
void notifyError ( const std::string &  msg,
int  curlm_code,
const std::string &  customId = "" 
)
protected
var notifyError ( var  msg,
var  curlm_code,
var  customId = "" 
)
protected
local notifyError ( local  msg,
local  curlm_code,
local  customId = "" 
)
protected
void notifyError ( const std::string &  msg,
const std::string &  customId,
int  curle_code 
)
protected
var notifyError ( var  msg,
var  customId,
var  curle_code 
)
protected
local notifyError ( local  msg,
local  customId,
local  curle_code 
)
protected
void prepareDownload ( const std::string &  srcUrl,
const std::string &  storagePath,
const std::string &  customId,
bool  resumeDownload,
FileDescriptor fDesc,
ProgressData pData 
)
protected
var prepareDownload ( var  srcUrl,
var  storagePath,
var  customId,
var  resumeDownload,
var  fDesc,
var  pData 
)
protected
local prepareDownload ( local  srcUrl,
local  storagePath,
local  customId,
local  resumeDownload,
local  fDesc,
local  pData 
)
protected
bool prepareHeader ( void *  curl,
const std::string &  srcUrl 
) const
protected
var prepareHeader ( var  curl,
var  srcUrl 
)
protected
local prepareHeader ( local  curl,
local  srcUrl 
)
protected
void setConnectionTimeout ( int  timeout)
var setConnectionTimeout ( var  timeout)
local setConnectionTimeout ( local  timeout)
void setErrorCallback ( const ErrorCallback callback)
inline
var setErrorCallback ( var  callback)
inline
local setErrorCallback ( local  callback)
inline
void setProgressCallback ( const ProgressCallback callback)
inline
var setProgressCallback ( var  callback)
inline
local setProgressCallback ( local  callback)
inline
void setSuccessCallback ( const SuccessCallback callback)
inline
var setSuccessCallback ( var  callback)
inline
local setSuccessCallback ( local  callback)
inline

Friends And Related Function Documentation

friend class AssetsManagerEx
friend
var AssetsManagerEx
friend
local AssetsManagerEx
friend

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