1
This commit is contained in:
parent
0733e51ec9
commit
3723810667
@ -123,8 +123,9 @@ static void SavePerfLog()
|
||||
f8::HttpClientPool::Instance()->max_user_request_delay = 0;
|
||||
}
|
||||
|
||||
bool App::Init(int argc, char* argv[])
|
||||
void App::Init()
|
||||
{
|
||||
#if 0
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
this->argc_ = argc;
|
||||
this->argv_ = argv;
|
||||
@ -227,6 +228,7 @@ bool App::Init(int argc, char* argv[])
|
||||
);
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::UnInit()
|
||||
@ -423,25 +425,25 @@ void App::ProcessGameGateMsg(f8::MsgHdr& hdr)
|
||||
if (handler) {
|
||||
switch (handler->handlerid) {
|
||||
case HID_RoomMgr:
|
||||
ProcessNetMsg(handler, RoomMgr::Instance(), hdr);
|
||||
ProcessNetMsg(handler, RoomMgr::Instance(), &hdr);
|
||||
break;
|
||||
case HID_MatchTeam:
|
||||
{
|
||||
auto match_info = MatchMgr::Instance()->GetMatchInfo(hdr.socket_handle);
|
||||
if (match_info) {
|
||||
ProcessNetMsg(handler, std::get<1>(*match_info).get(), hdr);
|
||||
ProcessNetMsg(handler, std::get<1>(*match_info).get(), &hdr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HID_PlayerMgr:
|
||||
ProcessNetMsg(handler, PlayerMgr::Instance(), hdr);
|
||||
ProcessNetMsg(handler, PlayerMgr::Instance(), &hdr);
|
||||
break;
|
||||
case HID_Player:
|
||||
{
|
||||
Player* hum = PlayerMgr::Instance()->GetPlayerBySocket(hdr.socket_handle);
|
||||
if (hum) {
|
||||
hdr.hum = hum;
|
||||
ProcessNetMsg(handler, hum, hdr);
|
||||
ProcessNetMsg(handler, hum, &hdr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -581,3 +583,18 @@ long long App::AllocTempWeaponUniId()
|
||||
++curr_uniid_;
|
||||
return -curr_uniid_;
|
||||
}
|
||||
|
||||
const std::string App::GetPkgName()
|
||||
{
|
||||
return a8::Format("gameserver2006", {});
|
||||
}
|
||||
|
||||
void App::Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void App::DispatchSocketMsg(f8::MsgHdr* hdr)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,10 @@
|
||||
#include <a8/singleton.h>
|
||||
|
||||
#include <f8/protoutils.h>
|
||||
#include <f8/app.h>
|
||||
|
||||
struct MsgNode;
|
||||
class App : public a8::Singleton<App>
|
||||
class App : public f8::UserApp, public a8::Singleton<App>
|
||||
{
|
||||
private:
|
||||
App() {};
|
||||
@ -17,8 +18,12 @@ public:
|
||||
std::map<int, int> debug_params;
|
||||
#endif
|
||||
|
||||
bool Init(int argc, char* argv[]);
|
||||
void UnInit();
|
||||
virtual const std::string GetPkgName() override;
|
||||
virtual void Init() override;
|
||||
virtual void UnInit() override;
|
||||
virtual void Update() override;
|
||||
virtual bool HasTask() override;
|
||||
virtual void DispatchSocketMsg(f8::MsgHdr* hdr) override;
|
||||
|
||||
int Run();
|
||||
|
||||
@ -51,7 +56,6 @@ private:
|
||||
void QuickExecute(int delta_time);
|
||||
void SlowerExecute(int delta_time);
|
||||
void Schedule();
|
||||
bool HasTask();
|
||||
|
||||
void DispatchMsg();
|
||||
|
||||
|
@ -22,50 +22,50 @@
|
||||
|
||||
static void _GMOpsSelfChecking(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||
{
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
request->resp_xobj->SetVal("healthy", 1);
|
||||
request->resp_xobj->SetVal("servicing", App::Instance()->IsServicing() ? 1 : 0);
|
||||
request->resp_xobj->SetVal("max_rundelay", PerfMonitor::Instance()->max_run_delay_time);
|
||||
request->resp_xobj->SetVal("max_timer_idle", PerfMonitor::Instance()->max_timer_idle);
|
||||
request->GetResp()->SetVal("errcode", 0);
|
||||
request->GetResp()->SetVal("errmsg", "");
|
||||
request->GetResp()->SetVal("healthy", 1);
|
||||
request->GetResp()->SetVal("servicing", App::Instance()->IsServicing() ? 1 : 0);
|
||||
request->GetResp()->SetVal("max_rundelay", PerfMonitor::Instance()->max_run_delay_time);
|
||||
request->GetResp()->SetVal("max_timer_idle", PerfMonitor::Instance()->max_timer_idle);
|
||||
}
|
||||
|
||||
static void _GMOpsStopService(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||
{
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
request->GetResp()->SetVal("errcode", 0);
|
||||
request->GetResp()->SetVal("errmsg", "");
|
||||
App::Instance()->SetServicing(false);
|
||||
}
|
||||
|
||||
static void _GMOpsStartService(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||
{
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
request->GetResp()->SetVal("errcode", 0);
|
||||
request->GetResp()->SetVal("errmsg", "");
|
||||
App::Instance()->SetServicing(true);
|
||||
}
|
||||
|
||||
static void _GMOpsServerInfo(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||
{
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
request->resp_xobj->SetVal("node_id", App::Instance()->GetNodeId());
|
||||
request->resp_xobj->SetVal("instance_id", App::Instance()->GetInstanceId());
|
||||
request->GetResp()->SetVal("errcode", 0);
|
||||
request->GetResp()->SetVal("errmsg", "");
|
||||
request->GetResp()->SetVal("node_id", App::Instance()->GetNodeId());
|
||||
request->GetResp()->SetVal("instance_id", App::Instance()->GetInstanceId());
|
||||
}
|
||||
|
||||
static void _GMOpsTerminate(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||
{
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
request->GetResp()->SetVal("errcode", 0);
|
||||
request->GetResp()->SetVal("errmsg", "");
|
||||
App::Instance()->Terminate();
|
||||
}
|
||||
|
||||
|
||||
static void _GMStatGetRealTimeOnline(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||
{
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
request->resp_xobj->SetVal("num", PerfMonitor::Instance()->entity_num[ET_Player]);
|
||||
request->resp_xobj->SetVal("room_num", RoomMgr::Instance()->RoomNum());
|
||||
request->GetResp()->SetVal("errcode", 0);
|
||||
request->GetResp()->SetVal("errmsg", "");
|
||||
request->GetResp()->SetVal("num", PerfMonitor::Instance()->entity_num[ET_Player]);
|
||||
request->GetResp()->SetVal("room_num", RoomMgr::Instance()->RoomNum());
|
||||
}
|
||||
|
||||
void HandlerMgr::Init()
|
||||
@ -103,6 +103,7 @@ void HandlerMgr::UnInit()
|
||||
|
||||
void HandlerMgr::RegisterNetMsgHandlers()
|
||||
{
|
||||
#if 0
|
||||
RegisterNetMsgHandler(&ggmsghandler, &PlayerMgr::_SS_WSP_SocketDisconnect);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &PlayerMgr::_SS_Ping);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMJoin);
|
||||
@ -132,6 +133,7 @@ void HandlerMgr::RegisterNetMsgHandlers()
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMTeamMarkTargetPos);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMSetRevivePosition);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMGetSettlementTeamList);
|
||||
#endif
|
||||
}
|
||||
|
||||
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
||||
@ -148,20 +150,22 @@ void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
||||
std::string msgname = a8::Get(request, "c").GetString() + "@" + a8::Get(request, "a").GetString();
|
||||
auto itr = gmhandlers_.find(msgname);
|
||||
if (itr != gmhandlers_.end()) {
|
||||
#if 0
|
||||
auto request = std::make_shared<f8::JsonHttpRequest>();
|
||||
request->saddr = saddr;
|
||||
request->socket_handle = sockhandle;
|
||||
request->query_str = querystr;
|
||||
request->params->ReadFromUrlQueryString(querystr);
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
request->GetResp()->SetVal("errcode", 0);
|
||||
request->GetResp()->SetVal("errmsg", "");
|
||||
itr->second(request);
|
||||
|
||||
if (!request->pending){
|
||||
std::string response;
|
||||
request->resp_xobj->ToJsonStr(response);
|
||||
request->GetResp()->ToJsonStr(response);
|
||||
GGListener::Instance()->SendText(sockhandle, a8::HttpResponse(response));
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
GGListener::Instance()->SendText(sockhandle, a8::HttpResponse("{}"));
|
||||
}
|
||||
|
@ -27,24 +27,24 @@ static void _ProxyCallback(std::shared_ptr<f8::JsonHttpRequest> request)
|
||||
#ifdef DEBUG
|
||||
f8::UdpLog::Instance()->Debug("ProxyCallbBack request:%s",
|
||||
{
|
||||
request->params->ToJsonStr()
|
||||
request->GetParams()->ToJsonStr()
|
||||
});
|
||||
#endif
|
||||
std::string seq_id = request->params->Get("seq_id");
|
||||
std::string seq_id = request->GetParams()->Get("seq_id");
|
||||
std::shared_ptr<HttpProxyRequest> req = HttpProxy::Instance()->GetRequest(seq_id);
|
||||
if (req) {
|
||||
a8::XObject data;
|
||||
|
||||
data.ReadFromJsonString(request->params->Get("data").GetString());
|
||||
data.ReadFromJsonString(request->GetParams()->Get("data").GetString());
|
||||
if (data.GetType() == a8::XOT_SIMPLE) {
|
||||
data.ReadFromJsonString("{}");
|
||||
}
|
||||
f8::HttpContext ctx;
|
||||
if (request->params->HasKey("errcode") &&
|
||||
request->params->Get("errcode").GetInt() == 0) {
|
||||
if (request->GetParams()->HasKey("errcode") &&
|
||||
request->GetParams()->Get("errcode").GetInt() == 0) {
|
||||
req->cb(true, &data, &ctx);
|
||||
} else {
|
||||
req->cb(false, request->params.get(), &ctx);
|
||||
req->cb(false, request->GetParams().get(), &ctx);
|
||||
}
|
||||
HttpProxy::Instance()->DestoryRequest(req);
|
||||
}
|
||||
|
@ -4,9 +4,11 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int exitcode = 0;
|
||||
#if 0
|
||||
if (App::Instance()->Init(argc, argv)) {
|
||||
exitcode = App::Instance()->Run();
|
||||
App::Instance()->UnInit();
|
||||
}
|
||||
#endif
|
||||
return exitcode;
|
||||
}
|
||||
|
2
third_party/f8
vendored
2
third_party/f8
vendored
@ -1 +1 @@
|
||||
Subproject commit 7fb9c9083275fd35c2bb4456999673444dcfe986
|
||||
Subproject commit 39cf53ed693b0c6e6d9119c38b894013ac9716e6
|
Loading…
x
Reference in New Issue
Block a user