From c3d8b2e56501880784aa26c15c0dd1f2ff226fcb Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 21 Mar 2022 14:11:21 +0800 Subject: [PATCH] 1 --- server/gameserver/httpproxy.cc | 25 ++++++++++++++++++++++--- server/gameserver/httpproxy.h | 3 ++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/server/gameserver/httpproxy.cc b/server/gameserver/httpproxy.cc index 50cf5e12..85c58ec7 100644 --- a/server/gameserver/httpproxy.cc +++ b/server/gameserver/httpproxy.cc @@ -1,10 +1,16 @@ #include "precompile.h" +#include + #include "httpproxy.h" +#include "app.h" + +#include "framework/cpp/httpclientpool.h" + void HttpProxy::Init() { - + request_prefix_ = "game2006_" + a8::XValue(a8::GetMilliSecond()).GetString() + "_"; } void HttpProxy::UnInit() @@ -19,10 +25,23 @@ std::string HttpProxy::HttpGet(a8::XParams param, a8::XObject url_params ) { - + std::string request_id = CreateRequestId(); + request_hash_[request_id] = param; + f8::HttpClientPool::Instance()->HttpGet + (a8::XParams() + //.SetSender(instance_id) + //.SetParam1(host) + .SetParam2(1), + on_ok, + on_error, + url, + url_params, + rand() % MAX_SYS_HTTP_NUM + ); + return request_id; } std::string HttpProxy::CreateRequestId() { - + return request_prefix_ + a8::XValue(App::Instance()->NewUuid()).GetString(); } diff --git a/server/gameserver/httpproxy.h b/server/gameserver/httpproxy.h index 11b7785f..65e750a0 100644 --- a/server/gameserver/httpproxy.h +++ b/server/gameserver/httpproxy.h @@ -26,6 +26,7 @@ class HttpProxy : public a8::Singleton std::string CreateRequestId(); private: - std::map get_hash_; + std::map request_hash_; + std::string request_prefix_; };