添加接口

This commit is contained in:
xiongziliang 2018-08-28 23:20:55 +08:00
parent 36d1d3aa16
commit d731454531
2 changed files with 8 additions and 1 deletions

View File

@ -57,14 +57,20 @@ API_EXPORT HttpDownloaderContex API_CALL createDownloader(){
return ret.get(); return ret.get();
} }
API_EXPORT void API_CALL downloader_startDownload(HttpDownloaderContex ctx,const char *url,downloader_onResult cb,void *userData){ API_EXPORT void API_CALL downloader_startDownload(HttpDownloaderContex ctx,const char *url,downloader_onResult cb,void *userData){
downloader_startDownload_l(ctx,url,"",cb,userData);
}
API_EXPORT void API_CALL downloader_startDownload_l(HttpDownloaderContex ctx,const char *url,const char *file,downloader_onResult cb,void *userData){
HttpDownloader *ptr = (HttpDownloader *)ctx; HttpDownloader *ptr = (HttpDownloader *)ctx;
string urlTmp(url); string urlTmp(url);
ptr->startDownload(url, [cb,userData,urlTmp](int code,const char *errMsg,const char *filePath){ ptr->setOnResult([cb,userData,urlTmp](int code,const char *errMsg,const char *filePath){
if(cb){ if(cb){
InfoL << code << " " << errMsg << " " << filePath << " " << urlTmp; InfoL << code << " " << errMsg << " " << filePath << " " << urlTmp;
cb(userData,code,errMsg,filePath); cb(userData,code,errMsg,filePath);
} }
}); });
ptr->startDownload(url,file,false);
} }
API_EXPORT void API_CALL releaseDownloader(HttpDownloaderContex ctx){ API_EXPORT void API_CALL releaseDownloader(HttpDownloaderContex ctx){
lock_guard<recursive_mutex> lck(s_mtxMapDownloader); lock_guard<recursive_mutex> lck(s_mtxMapDownloader);

View File

@ -39,6 +39,7 @@ typedef void(API_CALL *downloader_onResult)(void *userData,int code,const char *
API_EXPORT HttpDownloaderContex API_CALL createDownloader(); API_EXPORT HttpDownloaderContex API_CALL createDownloader();
API_EXPORT void API_CALL downloader_startDownload(HttpDownloaderContex ctx,const char *url,downloader_onResult cb,void *userData); API_EXPORT void API_CALL downloader_startDownload(HttpDownloaderContex ctx,const char *url,downloader_onResult cb,void *userData);
API_EXPORT void API_CALL downloader_startDownload_l(HttpDownloaderContex ctx,const char *url,const char *file,downloader_onResult cb,void *userData);
API_EXPORT void API_CALL releaseDownloader(HttpDownloaderContex ctx); API_EXPORT void API_CALL releaseDownloader(HttpDownloaderContex ctx);