diff --git a/server/gameserver/httpproxy.cc b/server/gameserver/httpproxy.cc index eb518c41..1cc443bf 100644 --- a/server/gameserver/httpproxy.cc +++ b/server/gameserver/httpproxy.cc @@ -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); } diff --git a/server/gameserver/httpproxy.h b/server/gameserver/httpproxy.h index d0ad116f..789ed01a 100644 --- a/server/gameserver/httpproxy.h +++ b/server/gameserver/httpproxy.h @@ -5,10 +5,6 @@ #include "f8/httpclientpool.h" struct HttpProxyRequest; -namespace f8 { - struct HttpContext; - typedef std::function HttpProxyCb; -} class HttpProxy : public a8::Singleton { diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 63af66b2..abb6ce8b 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -423,48 +423,41 @@ 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; - f8::Timer::Instance()->SetTimeoutEx - (1000, - [instance_id, host, port] (int event, const a8::Args* args) - { - if (a8::TIMER_EXEC_EVENT == event) { - RoomMgr::Instance()->ReportServerState( - instance_id, - host, - port - ); - } - }, - &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; - - f8::Timer::Instance()->SetTimeoutEx - (1000, - [instance_id, host, port] - (int event, const a8::Args* args) - { - if (a8::TIMER_EXEC_EVENT == event) { - RoomMgr::Instance()->ReportServerState - ( - instance_id, - host, - port - ); - } - }, - &RoomMgr::Instance()->reportstate_timer_attacher_); + if (ok) { + f8::Timer::Instance()->SetTimeoutEx + (1000, + [instance_id, host, port] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + RoomMgr::Instance()->ReportServerState( + instance_id, + host, + port + ); + } + }, + &RoomMgr::Instance()->reportstate_timer_attacher_); + } else { + f8::Timer::Instance()->SetTimeoutEx + (1000, + [instance_id, host, port] + (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + RoomMgr::Instance()->ReportServerState + ( + instance_id, + host, + port + ); + } + }, + &RoomMgr::Instance()->reportstate_timer_attacher_); + } }; std::string url = a8::Format("http://%s:%d/webapp/index.php?c=GS&a=report&", { @@ -481,16 +474,13 @@ 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, - url.c_str(), - *url_params, - rand() % MAX_SYS_HTTP_NUM - ); + f8::HttpClientPool::Instance()->HttpGet + ( + cb, + url.c_str(), + *url_params, + rand() % MAX_SYS_HTTP_NUM + ); delete url_params; } diff --git a/third_party/a8 b/third_party/a8 index 6c4e6fd4..e7c78838 160000 --- a/third_party/a8 +++ b/third_party/a8 @@ -1 +1 @@ -Subproject commit 6c4e6fd4e0f4b658f49f3b01df6f6bf6ae3af9f7 +Subproject commit e7c788386d78c403f36ecf31ce860a73f4ce8f64 diff --git a/third_party/f8 b/third_party/f8 index 6ca822b2..ce0c7e6c 160000 --- a/third_party/f8 +++ b/third_party/f8 @@ -1 +1 @@ -Subproject commit 6ca822b2c7f6c50f6d6dbb2aae22892846740e0d +Subproject commit ce0c7e6cfa18a6b6cc6437cc32bfc59d898ce115