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

65 lines
1.6 KiB
C
Raw Normal View History

#pragma once
2014-11-19 00:25:21 +08:00
//////////////////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>еĴ<D0B5><C4B4><EFBFBD><EFBFBD>ӿ<EFBFBD>
2014-11-19 00:25:21 +08:00
class rpc_callback
{
public:
rpc_callback() {}
virtual ~rpc_callback() {}
// <20><><EFBFBD><EFBFBD> HTTP <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
2014-11-19 00:25:21 +08:00
virtual void SetRequestHdr(const char* hdr) = 0;
// <20><><EFBFBD><EFBFBD> HTTP <20><>Ӧͷ<D3A6><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
2014-11-19 00:25:21 +08:00
virtual void SetResponseHdr(const char* hdr) = 0;
// <20><><EFBFBD>ع<EFBFBD><D8B9><EFBFBD><EFBFBD>еĻص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
2014-11-19 00:25:21 +08:00
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>
2014-11-19 00:25:21 +08:00
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>
2014-11-19 00:25:21 +08:00
*/
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>
2014-11-19 00:25:21 +08:00
*/
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>
2014-11-19 00:25:21 +08:00
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>Ϣ
2014-11-19 00:25:21 +08:00
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>Ϣ
2014-11-19 00:25:21 +08:00
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_;
};