1
This commit is contained in:
parent
a075615d14
commit
fe1d0a5def
@ -21,6 +21,7 @@
|
||||
#include <f8/utils.h>
|
||||
#include <f8/timer.h>
|
||||
|
||||
#if 0
|
||||
namespace f8
|
||||
{
|
||||
|
||||
@ -544,3 +545,4 @@ namespace f8
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#if 0
|
||||
namespace f8
|
||||
{
|
||||
typedef std::vector<std::vector<std::string>> DataSet;
|
||||
@ -37,3 +38,4 @@ namespace f8
|
||||
DBPoolImpl* impl_ = nullptr;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
@ -39,10 +39,14 @@ namespace f8
|
||||
struct AsyncHttpRequest
|
||||
{
|
||||
long long context_id = 0;
|
||||
#if 0
|
||||
a8::XParams param;
|
||||
#endif
|
||||
time_t add_time = 0;
|
||||
#if 0
|
||||
AsyncHttpOnOkFunc on_ok = nullptr;
|
||||
AsyncHttpOnErrorFunc on_error = nullptr;
|
||||
#endif
|
||||
f8::Attacher timer_attacher;
|
||||
};
|
||||
|
||||
@ -360,9 +364,11 @@ namespace f8
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
if (request->on_ok) {
|
||||
request->on_ok(request->param, data);
|
||||
}
|
||||
#endif
|
||||
async_http_hash.erase(seqid);
|
||||
delete request;
|
||||
}
|
||||
@ -373,13 +379,16 @@ namespace f8
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
if (request->on_error) {
|
||||
request->on_error(request->param, response);
|
||||
}
|
||||
#endif
|
||||
async_http_hash.erase(seqid);
|
||||
delete request;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void InternalExecAsyncHttp(int method, const char* url, a8::XObject& url_params,
|
||||
const char* content, a8::XObject* headers,
|
||||
a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error,
|
||||
@ -427,6 +436,7 @@ namespace f8
|
||||
},
|
||||
&p->timer_attacher);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if F8_MUTLI_THREAD_HTTP
|
||||
HttpThread* GetHttpThread(long long hash_code)
|
||||
@ -543,19 +553,27 @@ namespace f8
|
||||
#endif
|
||||
}
|
||||
|
||||
void HttpClientPool::HttpGet(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error,
|
||||
const char* url, a8::XObject url_params,
|
||||
long long hash_code, a8::XObject* headers)
|
||||
void HttpClientPool::HttpGet(f8::HttpProxyCb cb,
|
||||
const char* url,
|
||||
a8::XObject url_params,
|
||||
long long hash_code,
|
||||
a8::XObject* headers)
|
||||
|
||||
{
|
||||
#if 0
|
||||
impl_->InternalExecAsyncHttp(1, url, url_params, "", headers, param, on_ok, on_error, hash_code);
|
||||
#endif
|
||||
}
|
||||
|
||||
void HttpClientPool::HttpPost(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error,
|
||||
const char* url, a8::XObject url_params, const std::string& content,
|
||||
void HttpClientPool::HttpPost(f8::HttpProxyCb cb,
|
||||
const char* url,
|
||||
a8::XObject url_params,
|
||||
const std::string& content,
|
||||
long long hash_code, a8::XObject* headers)
|
||||
{
|
||||
#if 0
|
||||
impl_->InternalExecAsyncHttp(2, url, url_params, content.c_str(), headers, param, on_ok, on_error, hash_code);
|
||||
#endif
|
||||
}
|
||||
|
||||
long long HttpClientPool::GetPendingNum()
|
||||
|
@ -6,9 +6,6 @@ namespace f8
|
||||
struct HttpContext;
|
||||
typedef std::function<void(bool, a8::XObject*, f8::HttpContext*)> HttpProxyCb;
|
||||
|
||||
typedef void (*AsyncHttpOnOkFunc)(a8::XParams& param, a8::XObject& data);
|
||||
typedef void (*AsyncHttpOnErrorFunc)(a8::XParams& param, const std::string& response);
|
||||
|
||||
class HttpClientPoolImpl;
|
||||
class HttpClientPool : public a8::Singleton<HttpClientPool>
|
||||
{
|
||||
@ -28,13 +25,21 @@ namespace f8
|
||||
void UnInit();
|
||||
|
||||
//执行异步http get
|
||||
void HttpGet(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error,
|
||||
const char* url, a8::XObject url_params,
|
||||
long long hash_code, a8::XObject* headers = nullptr);
|
||||
void HttpGet(
|
||||
f8::HttpProxyCb cb,
|
||||
const char* url,
|
||||
a8::XObject url_params,
|
||||
long long hash_code,
|
||||
a8::XObject* headers = nullptr);
|
||||
//执行异步http post
|
||||
void HttpPost(a8::XParams param, AsyncHttpOnOkFunc on_ok, AsyncHttpOnErrorFunc on_error,
|
||||
const char* url, a8::XObject url_params, const std::string& content,
|
||||
long long hash_code, a8::XObject* headers = nullptr);
|
||||
void HttpPost(
|
||||
f8::HttpProxyCb cb,
|
||||
const char* url,
|
||||
a8::XObject url_params,
|
||||
const std::string& content,
|
||||
long long hash_code,
|
||||
a8::XObject* headers = nullptr);
|
||||
|
||||
//获取执行中的数量
|
||||
long long GetPendingNum();
|
||||
HttpClientPoolImpl* Impl();
|
||||
|
Loading…
x
Reference in New Issue
Block a user