1
This commit is contained in:
parent
c43ded4696
commit
3b30957e37
@ -84,17 +84,17 @@ void GSMgr::_SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg)
|
|||||||
GGListener::Instance()->SendMsg(hdr.socket_handle, pongmsg);
|
GGListener::Instance()->SendMsg(hdr.socket_handle, pongmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSMgr::___GSReport(f8::JsonHttpRequest* request)
|
void GSMgr::___GSReport(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||||
{
|
{
|
||||||
std::string ip = request->params->Get("ip");
|
std::string ip = request->GetParams()->Get("ip");
|
||||||
int port = request->params->Get("port");
|
int port = request->GetParams()->Get("port");
|
||||||
int alive_count = request->params->Get("alive_count");
|
int alive_count = request->GetParams()->Get("alive_count");
|
||||||
int online_num = request->params->Get("online_num");
|
int online_num = request->GetParams()->Get("online_num");
|
||||||
int room_num = request->params->Get("room_num");
|
int room_num = request->GetParams()->Get("room_num");
|
||||||
int instance_id = request->params->Get("instance_id");
|
int instance_id = request->GetParams()->Get("instance_id");
|
||||||
int node_id = request->params->Get("node_id");
|
int node_id = request->GetParams()->Get("node_id");
|
||||||
int version = request->params->Get("version");
|
int version = request->GetParams()->Get("version");
|
||||||
bool servicing = request->params->Get("servicing");
|
bool servicing = request->GetParams()->Get("servicing");
|
||||||
std::string key = ip + ":" + a8::XValue(port).GetString();
|
std::string key = ip + ":" + a8::XValue(port).GetString();
|
||||||
|
|
||||||
auto itr = node_key_hash_.find(key);
|
auto itr = node_key_hash_.find(key);
|
||||||
@ -135,11 +135,11 @@ void GSMgr::___GSReport(f8::JsonHttpRequest* request)
|
|||||||
RearrangeNode();
|
RearrangeNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
request->resp_xobj->SetVal("errcode", 0);
|
request->GetResp()->SetVal("errcode", 0);
|
||||||
request->resp_xobj->SetVal("errmsg", "");
|
request->GetResp()->SetVal("errmsg", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSMgr::___GSList(f8::JsonHttpRequest* request)
|
void GSMgr::___GSList(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto node_list = a8::MutableXObject::CreateArray();
|
auto node_list = a8::MutableXObject::CreateArray();
|
||||||
@ -158,9 +158,9 @@ void GSMgr::___GSList(f8::JsonHttpRequest* request)
|
|||||||
node_list->Push(*node);
|
node_list->Push(*node);
|
||||||
}
|
}
|
||||||
|
|
||||||
request->resp_xobj->SetVal("errcode", 0);
|
request->GetResp()->SetVal("errcode", 0);
|
||||||
request->resp_xobj->SetVal("errmsg", "");
|
request->GetResp()->SetVal("errmsg", "");
|
||||||
request->resp_xobj->SetVal("node_list", *node_list);
|
request->GetResp()->SetVal("node_list", *node_list);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto node_list = a8::MutableXObject::CreateArray();
|
auto node_list = a8::MutableXObject::CreateArray();
|
||||||
@ -180,9 +180,9 @@ void GSMgr::___GSList(f8::JsonHttpRequest* request)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
request->resp_xobj->SetVal("errcode", 0);
|
request->GetResp()->SetVal("errcode", 0);
|
||||||
request->resp_xobj->SetVal("errmsg", "");
|
request->GetResp()->SetVal("errmsg", "");
|
||||||
request->resp_xobj->SetVal("sorted_node_list", *node_list);
|
request->GetResp()->SetVal("sorted_node_list", *node_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ class GSMgr : public a8::Singleton<GSMgr>
|
|||||||
void _SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_RequestTargetServer& msg);
|
void _SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_RequestTargetServer& msg);
|
||||||
void _SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg);
|
void _SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg);
|
||||||
|
|
||||||
void ___GSReport(f8::JsonHttpRequest* request);
|
void ___GSReport(std::shared_ptr<f8::JsonHttpRequest> request);
|
||||||
void ___GSList(f8::JsonHttpRequest* request);
|
void ___GSList(std::shared_ptr<f8::JsonHttpRequest> request);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<GSNode> GetNodeByTeamId(const std::string& team_id);
|
std::shared_ptr<GSNode> GetNodeByTeamId(const std::string& team_id);
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
#include "ss_proto.pb.h"
|
#include "ss_proto.pb.h"
|
||||||
|
|
||||||
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
static void _GMOpsSelfChecking(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||||
{
|
{
|
||||||
request->resp_xobj->SetVal("errcode", 0);
|
request->GetResp()->SetVal("errcode", 0);
|
||||||
request->resp_xobj->SetVal("errmsg", "");
|
request->GetResp()->SetVal("errmsg", "");
|
||||||
request->resp_xobj->SetVal("healthy", 1);
|
request->GetResp()->SetVal("healthy", 1);
|
||||||
request->resp_xobj->SetVal("max_rundelay", App::Instance()->perf.max_run_delay_time);
|
request->GetResp()->SetVal("max_rundelay", App::Instance()->perf.max_run_delay_time);
|
||||||
request->resp_xobj->SetVal("max_timer_idle", App::Instance()->perf.max_timer_idle);
|
request->GetResp()->SetVal("max_timer_idle", App::Instance()->perf.max_timer_idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlerMgr::Init()
|
void HandlerMgr::Init()
|
||||||
@ -25,12 +25,12 @@ void HandlerMgr::Init()
|
|||||||
RegisterNetMsgHandlers();
|
RegisterNetMsgHandlers();
|
||||||
RegisterGMMsgHandler("Ops@selfChecking", _GMOpsSelfChecking);
|
RegisterGMMsgHandler("Ops@selfChecking", _GMOpsSelfChecking);
|
||||||
RegisterGMMsgHandler("GS@report",
|
RegisterGMMsgHandler("GS@report",
|
||||||
[] (f8::JsonHttpRequest* request)
|
[] (std::shared_ptr<f8::JsonHttpRequest> request)
|
||||||
{
|
{
|
||||||
GSMgr::Instance()->___GSReport(request);
|
GSMgr::Instance()->___GSReport(request);
|
||||||
});
|
});
|
||||||
RegisterGMMsgHandler("GS@list",
|
RegisterGMMsgHandler("GS@list",
|
||||||
[] (f8::JsonHttpRequest* request)
|
[] (std::shared_ptr<f8::JsonHttpRequest> request)
|
||||||
{
|
{
|
||||||
GSMgr::Instance()->___GSList(request);
|
GSMgr::Instance()->___GSList(request);
|
||||||
});
|
});
|
||||||
@ -60,29 +60,24 @@ void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
|||||||
std::string msgname = a8::Get(request, "c").GetString() + "@" + a8::Get(request, "a").GetString();
|
std::string msgname = a8::Get(request, "c").GetString() + "@" + a8::Get(request, "a").GetString();
|
||||||
auto itr = gmhandlers_.find(msgname);
|
auto itr = gmhandlers_.find(msgname);
|
||||||
if (itr != gmhandlers_.end()) {
|
if (itr != gmhandlers_.end()) {
|
||||||
f8::JsonHttpRequest* request = new f8::JsonHttpRequest;
|
auto request = std::make_shared<f8::JsonHttpRequest>
|
||||||
request->saddr = saddr;
|
(
|
||||||
request->socket_handle = sockhandle;
|
saddr,
|
||||||
request->query_str = querystr;
|
url,
|
||||||
request->params->ReadFromUrlQueryString(querystr);
|
querystr,
|
||||||
request->resp_xobj->SetVal("errcode", 0);
|
[sockhandle] (const a8::Args& args)
|
||||||
request->resp_xobj->SetVal("errmsg", "");
|
{
|
||||||
|
std::string data = args.Get<std::string>(0);
|
||||||
|
GGListener::Instance()->SendText(sockhandle, a8::HttpResponse(data));
|
||||||
|
});
|
||||||
itr->second(request);
|
itr->second(request);
|
||||||
|
|
||||||
if (!request->pending){
|
|
||||||
std::string response;
|
|
||||||
request->resp_xobj->ToJsonStr(response);
|
|
||||||
GGListener::Instance()->SendText(sockhandle, a8::HttpResponse(response));
|
|
||||||
|
|
||||||
delete request;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
GGListener::Instance()->SendText(sockhandle, a8::HttpResponse("{}"));
|
GGListener::Instance()->SendText(sockhandle, a8::HttpResponse("{}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlerMgr::RegisterGMMsgHandler(const std::string& msgname,
|
void HandlerMgr::RegisterGMMsgHandler(const std::string& msgname,
|
||||||
void (*handler)(f8::JsonHttpRequest*))
|
void (*handler)(std::shared_ptr<f8::JsonHttpRequest>))
|
||||||
{
|
{
|
||||||
gmhandlers_[msgname] = handler;
|
gmhandlers_[msgname] = handler;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class HandlerMgr : public a8::Singleton<HandlerMgr>
|
|||||||
private:
|
private:
|
||||||
void RegisterNetMsgHandlers();
|
void RegisterNetMsgHandlers();
|
||||||
void RegisterGMMsgHandler(const std::string& msgname,
|
void RegisterGMMsgHandler(const std::string& msgname,
|
||||||
void (*)(f8::JsonHttpRequest*));
|
void (*)(std::shared_ptr<f8::JsonHttpRequest>));
|
||||||
|
|
||||||
std::map<std::string, void (*)(f8::JsonHttpRequest*)> gmhandlers_;
|
std::map<std::string, void (*)(std::shared_ptr<f8::JsonHttpRequest>)> gmhandlers_;
|
||||||
};
|
};
|
||||||
|
2
third_party/f8
vendored
2
third_party/f8
vendored
@ -1 +1 @@
|
|||||||
Subproject commit ae2a2bcddbacf26d0ba2f1be7c95ee9e20ce3023
|
Subproject commit 5954fb5fcbf28bdeb16490ced77999daf2c0d73d
|
Loading…
x
Reference in New Issue
Block a user