This commit is contained in:
aozhiwei 2022-12-18 14:04:07 +08:00
parent 79d4e61bcd
commit dd43155cb1
5 changed files with 47 additions and 60 deletions

View File

@ -15,9 +15,6 @@
struct HttpProxyRequest
{
std::string req_id;
a8::XParams param;
f8::AsyncHttpOnOkFunc on_ok;
f8::AsyncHttpOnErrorFunc on_error;
std::string url;
a8::XObject url_params;
long long add_tick = 0;
@ -42,9 +39,13 @@ static void _ProxyCallback(f8::JsonHttpRequest* request)
}
if (request->request.HasKey("errcode") &&
request->request.Get("errcode").GetInt() == 0) {
#if 0
req->on_ok(req->param, data);
#endif
} else {
#if 0
req->on_error(req->param, data.Get("errmsg").GetString());
#endif
}
HttpProxy::Instance()->DestoryRequest(req);
}

View File

@ -5,10 +5,6 @@
#include "f8/httpclientpool.h"
struct HttpProxyRequest;
namespace f8 {
struct HttpContext;
typedef std::function<void(bool, a8::XObject*, f8::HttpContext*)> HttpProxyCb;
}
class HttpProxy : public a8::Singleton<HttpProxy>
{

View File

@ -423,12 +423,11 @@ void RoomMgr::ActiveRoom(long long room_uuid)
void RoomMgr::ReportServerState(int instance_id, const std::string& host, int port)
{
auto on_ok =
[] (a8::XParams& param, a8::XObject& data)
auto cb =
[instance_id, host, port]
(bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
{
int instance_id = param.sender;
std::string host = param.param1.GetString();
int port = param.param2;
if (ok) {
f8::Timer::Instance()->SetTimeoutEx
(1000,
[instance_id, host, port] (int event, const a8::Args* args)
@ -442,14 +441,7 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po
}
},
&RoomMgr::Instance()->reportstate_timer_attacher_);
};
auto on_error =
[] (a8::XParams& param, const std::string& response)
{
int instance_id = param.sender;
std::string host = param.param1.GetString();
int port = param.param2;
} else {
f8::Timer::Instance()->SetTimeoutEx
(1000,
[instance_id, host, port]
@ -465,6 +457,7 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po
}
},
&RoomMgr::Instance()->reportstate_timer_attacher_);
}
};
std::string url = a8::Format("http://%s:%d/webapp/index.php?c=GS&a=report&",
{
@ -481,12 +474,9 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po
url_params->SetVal("channel", JsonDataMgr::Instance()->channel);
url_params->SetVal("alive_count", PerfMonitor::Instance()->real_alive_count);
url_params->SetVal("servicing", App::Instance()->servicing ? 1 : 0);
f8::HttpClientPool::Instance()->HttpGet(a8::XParams()
.SetSender(instance_id)
.SetParam1(host)
.SetParam2(port),
on_ok,
on_error,
f8::HttpClientPool::Instance()->HttpGet
(
cb,
url.c_str(),
*url_params,
rand() % MAX_SYS_HTTP_NUM

2
third_party/a8 vendored

@ -1 +1 @@
Subproject commit 6c4e6fd4e0f4b658f49f3b01df6f6bf6ae3af9f7
Subproject commit e7c788386d78c403f36ecf31ce860a73f4ce8f64

2
third_party/f8 vendored

@ -1 +1 @@
Subproject commit 6ca822b2c7f6c50f6d6dbb2aae22892846740e0d
Subproject commit ce0c7e6cfa18a6b6cc6437cc32bfc59d898ce115