1
This commit is contained in:
parent
9db0fca841
commit
0b91fa9442
@ -13,15 +13,8 @@
|
|||||||
#include "framework/cpp/netmsghandler.h"
|
#include "framework/cpp/netmsghandler.h"
|
||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "GCListener.h"
|
|
||||||
#include "jsondatamgr.h"
|
#include "jsondatamgr.h"
|
||||||
#include "handlermgr.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
|
struct MsgNode
|
||||||
{
|
{
|
||||||
@ -89,10 +82,7 @@ void App::Init(int argc, char* argv[])
|
|||||||
HandlerMgr::Instance()->Init();
|
HandlerMgr::Instance()->Init();
|
||||||
a8::Timer::Instance()->Init();
|
a8::Timer::Instance()->Init();
|
||||||
JsonDataMgr::Instance()->Init();
|
JsonDataMgr::Instance()->Init();
|
||||||
GCListener::Instance()->Init();
|
|
||||||
uuid.SetMachineId(instance_id);
|
uuid.SetMachineId(instance_id);
|
||||||
GameClientMgr::Instance()->Init();
|
|
||||||
TargetConnMgr::Instance()->Init();
|
|
||||||
|
|
||||||
a8::UdpLog::Instance()->Info("masterserver starting instance_id:%d pid:%d", {instance_id, getpid()});
|
a8::UdpLog::Instance()->Info("masterserver starting instance_id:%d pid:%d", {instance_id, getpid()});
|
||||||
{
|
{
|
||||||
@ -114,9 +104,6 @@ void App::UnInit()
|
|||||||
if (terminated) {
|
if (terminated) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TargetConnMgr::Instance()->UnInit();
|
|
||||||
GameClientMgr::Instance()->UnInit();
|
|
||||||
GCListener::Instance()->UnInit();
|
|
||||||
JsonDataMgr::Instance()->UnInit();
|
JsonDataMgr::Instance()->UnInit();
|
||||||
a8::Timer::Instance()->UnInit();
|
a8::Timer::Instance()->UnInit();
|
||||||
HandlerMgr::Instance()->UnInit();
|
HandlerMgr::Instance()->UnInit();
|
||||||
@ -289,18 +276,10 @@ void App::DispatchMsg()
|
|||||||
hdr.buflen = pdelnode->buflen;
|
hdr.buflen = pdelnode->buflen;
|
||||||
hdr.offset = 0;
|
hdr.offset = 0;
|
||||||
hdr.ip_saddr = pdelnode->ip_saddr;
|
hdr.ip_saddr = pdelnode->ip_saddr;
|
||||||
|
#if 0
|
||||||
switch (pdelnode->sockfrom) {
|
switch (pdelnode->sockfrom) {
|
||||||
case SF_Client:
|
|
||||||
{
|
|
||||||
ProcessClientMsg(hdr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SF_TargetServer:
|
|
||||||
{
|
|
||||||
ProcessTargetServerMsg(hdr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (pdelnode->buf) {
|
if (pdelnode->buf) {
|
||||||
free(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()
|
void App::ProcessIMMsg()
|
||||||
{
|
{
|
||||||
if (!im_work_node_ && im_top_node_) {
|
if (!im_work_node_ && im_top_node_) {
|
||||||
@ -370,16 +307,6 @@ void App::ProcessIMMsg()
|
|||||||
while (im_work_node_) {
|
while (im_work_node_) {
|
||||||
IMMsgNode *pdelnode = im_work_node_;
|
IMMsgNode *pdelnode = im_work_node_;
|
||||||
switch (im_work_node_->msgid) {
|
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:
|
case IM_ExecGM:
|
||||||
{
|
{
|
||||||
HandlerMgr::Instance()->ProcGMMsg(pdelnode->params.param3,
|
HandlerMgr::Instance()->ProcGMMsg(pdelnode->params.param3,
|
||||||
|
@ -41,9 +41,6 @@ private:
|
|||||||
void DispatchMsg();
|
void DispatchMsg();
|
||||||
void ProcessIMMsg();
|
void ProcessIMMsg();
|
||||||
|
|
||||||
void ProcessClientMsg(f8::MsgHdr& hdr);
|
|
||||||
void ProcessTargetServerMsg(f8::MsgHdr& hdr);
|
|
||||||
|
|
||||||
void InitLog();
|
void InitLog();
|
||||||
void UnInitLog();
|
void UnInitLog();
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
#include "handlermgr.h"
|
#include "handlermgr.h"
|
||||||
|
|
||||||
#include "GCListener.h"
|
|
||||||
|
|
||||||
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
||||||
{
|
{
|
||||||
request->resp_xobj->SetVal("errcode", 0);
|
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)
|
const std::string& url, const std::string& querystr)
|
||||||
{
|
{
|
||||||
if (url != "/webapp/index.php") {
|
if (url != "/webapp/index.php") {
|
||||||
|
#if 0
|
||||||
GCListener::Instance()->SendText(sockhandle, a8::HttpResponse(404, ""));
|
GCListener::Instance()->SendText(sockhandle, a8::HttpResponse(404, ""));
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,12 +52,16 @@ void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
|||||||
if (!request->pending){
|
if (!request->pending){
|
||||||
std::string response;
|
std::string response;
|
||||||
request->resp_xobj->ToJsonStr(response);
|
request->resp_xobj->ToJsonStr(response);
|
||||||
|
#if 0
|
||||||
GCListener::Instance()->SendText(sockhandle, a8::HttpResponse(response));
|
GCListener::Instance()->SendText(sockhandle, a8::HttpResponse(response));
|
||||||
|
#endif
|
||||||
|
|
||||||
delete request;
|
delete request;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#if 0
|
||||||
GCListener::Instance()->SendText(sockhandle, a8::HttpResponse("{}"));
|
GCListener::Instance()->SendText(sockhandle, a8::HttpResponse("{}"));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user