acl/lib_acl_cpp/samples/gui_rpc/rpc/http_download.h

65 lines
1.6 KiB
C
Raw Normal View History

2014-11-19 00:25:21 +08:00
#pragma once
//////////////////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>еĴ<D0B5><C4B4><EFBFBD><EFBFBD>ӿ<EFBFBD>
class rpc_callback
{
public:
rpc_callback() {}
virtual ~rpc_callback() {}
// <20><><EFBFBD><EFBFBD> HTTP <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
virtual void SetRequestHdr(const char* hdr) = 0;
// <20><><EFBFBD><EFBFBD> HTTP <20><>Ӧͷ<D3A6><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
virtual void SetResponseHdr(const char* hdr) = 0;
// <20><><EFBFBD>ع<EFBFBD><D8B9><EFBFBD><EFBFBD>еĻص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
virtual void OnDownloading(long long int content_length,
long long int total_read) = 0;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
virtual void OnDownloadOver(long long int total_read,
double spent) = 0;
};
//////////////////////////////////////////////////////////////////////////
/**
* http <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><EFBFBD>з<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
*/
class http_download : public acl::rpc_request
{
public:
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param addr {const char*} HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>domain:port
* @param url {const char*} http url <EFBFBD><EFBFBD>ַ
* @param callback {rpc_callback*} http <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ֪ͨ<EFBFBD><EFBFBD><EFBFBD>̹߳<EFBFBD><EFBFBD><EFBFBD>
*/
http_download(const char* addr, const char* url,
rpc_callback* callback);
protected:
~http_download() {}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴߳<DFB3><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
virtual void rpc_run();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴߳<DFB3><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>Ϣ
virtual void rpc_onover();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴߳<DFB3><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>̵߳<DFB3>֪ͨ<CDA8><D6AA>Ϣ
virtual void rpc_wakeup(void* ctx);
private:
acl::string addr_;
acl::string url_;
acl::string req_hdr_;
acl::string res_hdr_;
bool error_;
long long int total_read_;
long long int content_length_;
double total_spent_;
rpc_callback* callback_;
};