1
This commit is contained in:
parent
79d4e61bcd
commit
dd43155cb1
@ -15,9 +15,6 @@
|
|||||||
struct HttpProxyRequest
|
struct HttpProxyRequest
|
||||||
{
|
{
|
||||||
std::string req_id;
|
std::string req_id;
|
||||||
a8::XParams param;
|
|
||||||
f8::AsyncHttpOnOkFunc on_ok;
|
|
||||||
f8::AsyncHttpOnErrorFunc on_error;
|
|
||||||
std::string url;
|
std::string url;
|
||||||
a8::XObject url_params;
|
a8::XObject url_params;
|
||||||
long long add_tick = 0;
|
long long add_tick = 0;
|
||||||
@ -42,9 +39,13 @@ static void _ProxyCallback(f8::JsonHttpRequest* request)
|
|||||||
}
|
}
|
||||||
if (request->request.HasKey("errcode") &&
|
if (request->request.HasKey("errcode") &&
|
||||||
request->request.Get("errcode").GetInt() == 0) {
|
request->request.Get("errcode").GetInt() == 0) {
|
||||||
|
#if 0
|
||||||
req->on_ok(req->param, data);
|
req->on_ok(req->param, data);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#if 0
|
||||||
req->on_error(req->param, data.Get("errmsg").GetString());
|
req->on_error(req->param, data.Get("errmsg").GetString());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
HttpProxy::Instance()->DestoryRequest(req);
|
HttpProxy::Instance()->DestoryRequest(req);
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,6 @@
|
|||||||
#include "f8/httpclientpool.h"
|
#include "f8/httpclientpool.h"
|
||||||
|
|
||||||
struct HttpProxyRequest;
|
struct HttpProxyRequest;
|
||||||
namespace f8 {
|
|
||||||
struct HttpContext;
|
|
||||||
typedef std::function<void(bool, a8::XObject*, f8::HttpContext*)> HttpProxyCb;
|
|
||||||
}
|
|
||||||
class HttpProxy : public a8::Singleton<HttpProxy>
|
class HttpProxy : public a8::Singleton<HttpProxy>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -423,48 +423,41 @@ void RoomMgr::ActiveRoom(long long room_uuid)
|
|||||||
|
|
||||||
void RoomMgr::ReportServerState(int instance_id, const std::string& host, int port)
|
void RoomMgr::ReportServerState(int instance_id, const std::string& host, int port)
|
||||||
{
|
{
|
||||||
auto on_ok =
|
auto cb =
|
||||||
[] (a8::XParams& param, a8::XObject& data)
|
[instance_id, host, port]
|
||||||
|
(bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
|
||||||
{
|
{
|
||||||
int instance_id = param.sender;
|
if (ok) {
|
||||||
std::string host = param.param1.GetString();
|
f8::Timer::Instance()->SetTimeoutEx
|
||||||
int port = param.param2;
|
(1000,
|
||||||
f8::Timer::Instance()->SetTimeoutEx
|
[instance_id, host, port] (int event, const a8::Args* args)
|
||||||
(1000,
|
{
|
||||||
[instance_id, host, port] (int event, const a8::Args* args)
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
{
|
RoomMgr::Instance()->ReportServerState(
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
instance_id,
|
||||||
RoomMgr::Instance()->ReportServerState(
|
host,
|
||||||
instance_id,
|
port
|
||||||
host,
|
);
|
||||||
port
|
}
|
||||||
);
|
},
|
||||||
}
|
&RoomMgr::Instance()->reportstate_timer_attacher_);
|
||||||
},
|
} else {
|
||||||
&RoomMgr::Instance()->reportstate_timer_attacher_);
|
f8::Timer::Instance()->SetTimeoutEx
|
||||||
};
|
(1000,
|
||||||
auto on_error =
|
[instance_id, host, port]
|
||||||
[] (a8::XParams& param, const std::string& response)
|
(int event, const a8::Args* args)
|
||||||
{
|
{
|
||||||
int instance_id = param.sender;
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
std::string host = param.param1.GetString();
|
RoomMgr::Instance()->ReportServerState
|
||||||
int port = param.param2;
|
(
|
||||||
|
instance_id,
|
||||||
f8::Timer::Instance()->SetTimeoutEx
|
host,
|
||||||
(1000,
|
port
|
||||||
[instance_id, host, port]
|
);
|
||||||
(int event, const a8::Args* args)
|
}
|
||||||
{
|
},
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
&RoomMgr::Instance()->reportstate_timer_attacher_);
|
||||||
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&",
|
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("channel", JsonDataMgr::Instance()->channel);
|
||||||
url_params->SetVal("alive_count", PerfMonitor::Instance()->real_alive_count);
|
url_params->SetVal("alive_count", PerfMonitor::Instance()->real_alive_count);
|
||||||
url_params->SetVal("servicing", App::Instance()->servicing ? 1 : 0);
|
url_params->SetVal("servicing", App::Instance()->servicing ? 1 : 0);
|
||||||
f8::HttpClientPool::Instance()->HttpGet(a8::XParams()
|
f8::HttpClientPool::Instance()->HttpGet
|
||||||
.SetSender(instance_id)
|
(
|
||||||
.SetParam1(host)
|
cb,
|
||||||
.SetParam2(port),
|
url.c_str(),
|
||||||
on_ok,
|
*url_params,
|
||||||
on_error,
|
rand() % MAX_SYS_HTTP_NUM
|
||||||
url.c_str(),
|
);
|
||||||
*url_params,
|
|
||||||
rand() % MAX_SYS_HTTP_NUM
|
|
||||||
);
|
|
||||||
delete url_params;
|
delete url_params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
third_party/a8
vendored
2
third_party/a8
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 6c4e6fd4e0f4b658f49f3b01df6f6bf6ae3af9f7
|
Subproject commit e7c788386d78c403f36ecf31ce860a73f4ce8f64
|
2
third_party/f8
vendored
2
third_party/f8
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 6ca822b2c7f6c50f6d6dbb2aae22892846740e0d
|
Subproject commit ce0c7e6cfa18a6b6cc6437cc32bfc59d898ce115
|
Loading…
x
Reference in New Issue
Block a user