This commit is contained in:
aozhiwei 2019-03-26 11:09:51 +08:00
parent 9db0fca841
commit 0b91fa9442
3 changed files with 8 additions and 80 deletions

View File

@ -13,15 +13,8 @@
#include "framework/cpp/netmsghandler.h"
#include "app.h"
#include "GCListener.h"
#include "jsondatamgr.h"
#include "handlermgr.h"
#include "target_conn.h"
#include "target_conn_mgr.h"
#include "gameclient.h"
#include "gameclientmgr.h"
#include "ss_msgid.pb.h"
#include "ss_proto.pb.h"
struct MsgNode
{
@ -89,10 +82,7 @@ void App::Init(int argc, char* argv[])
HandlerMgr::Instance()->Init();
a8::Timer::Instance()->Init();
JsonDataMgr::Instance()->Init();
GCListener::Instance()->Init();
uuid.SetMachineId(instance_id);
GameClientMgr::Instance()->Init();
TargetConnMgr::Instance()->Init();
a8::UdpLog::Instance()->Info("masterserver starting instance_id:%d pid:%d", {instance_id, getpid()});
{
@ -114,9 +104,6 @@ void App::UnInit()
if (terminated) {
return;
}
TargetConnMgr::Instance()->UnInit();
GameClientMgr::Instance()->UnInit();
GCListener::Instance()->UnInit();
JsonDataMgr::Instance()->UnInit();
a8::Timer::Instance()->UnInit();
HandlerMgr::Instance()->UnInit();
@ -289,18 +276,10 @@ void App::DispatchMsg()
hdr.buflen = pdelnode->buflen;
hdr.offset = 0;
hdr.ip_saddr = pdelnode->ip_saddr;
#if 0
switch (pdelnode->sockfrom) {
case SF_Client:
{
ProcessClientMsg(hdr);
}
break;
case SF_TargetServer:
{
ProcessTargetServerMsg(hdr);
}
break;
}
#endif
if (pdelnode->buf) {
free(pdelnode->buf);
}
@ -316,48 +295,6 @@ void App::DispatchMsg()
}
}
void App::ProcessClientMsg(f8::MsgHdr& hdr)
{
if (hdr.msgid < 100) {
return;
}
TargetConn* conn = nullptr;
if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReConnect) {
ss::SS_CMLogin_CMReConnect_CommonHead msg;
bool ok = msg.ParseFromArray(hdr.buf + hdr.offset, hdr.buflen - hdr.offset);
if (ok) {
conn = TargetConnMgr::Instance()->GetConnByInstanceId(msg.server_id());
if (!conn) {
ss::SS_SMRpcError respmsg;
respmsg.set_error_code(10);
GCListener::Instance()->SendMsg(hdr.socket_handle, respmsg);
}
} else {
return;
}
} else {
GameClient* client = GameClientMgr::Instance()->GetGameClientBySocket(hdr.socket_handle);
if (client) {
conn = client->conn;
}
}
if (conn) {
conn->ForwardClientMsg(hdr);
}
}
void App::ProcessTargetServerMsg(f8::MsgHdr& hdr)
{
if (hdr.msgid < 100) {
return;
}
if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReConnect) {
GameClientMgr::Instance()->BindTargetConn(hdr.socket_handle, hdr.ip_saddr);
GCListener::Instance()->MarkClient(hdr.socket_handle, true);
}
GCListener::Instance()->ForwardTargetConnMsg(hdr);
}
void App::ProcessIMMsg()
{
if (!im_work_node_ && im_top_node_) {
@ -370,16 +307,6 @@ void App::ProcessIMMsg()
while (im_work_node_) {
IMMsgNode *pdelnode = im_work_node_;
switch (im_work_node_->msgid) {
case IM_ClientSocketDisconnect:
{
GameClientMgr::Instance()->OnClientDisconnect(pdelnode->params);
}
break;
case IM_TargetConnDisconnect:
{
GameClientMgr::Instance()->OnTargetServerDisconnect(pdelnode->params);
}
break;
case IM_ExecGM:
{
HandlerMgr::Instance()->ProcGMMsg(pdelnode->params.param3,

View File

@ -41,9 +41,6 @@ private:
void DispatchMsg();
void ProcessIMMsg();
void ProcessClientMsg(f8::MsgHdr& hdr);
void ProcessTargetServerMsg(f8::MsgHdr& hdr);
void InitLog();
void UnInitLog();

View File

@ -4,8 +4,6 @@
#include "handlermgr.h"
#include "GCListener.h"
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
{
request->resp_xobj->SetVal("errcode", 0);
@ -32,7 +30,9 @@ void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
const std::string& url, const std::string& querystr)
{
if (url != "/webapp/index.php") {
#if 0
GCListener::Instance()->SendText(sockhandle, a8::HttpResponse(404, ""));
#endif
return;
}
@ -52,12 +52,16 @@ void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
if (!request->pending){
std::string response;
request->resp_xobj->ToJsonStr(response);
#if 0
GCListener::Instance()->SendText(sockhandle, a8::HttpResponse(response));
#endif
delete request;
}
} else {
#if 0
GCListener::Instance()->SendText(sockhandle, a8::HttpResponse("{}"));
#endif
}
}