add imsmgr

This commit is contained in:
aozhiwei 2020-05-02 22:48:43 +08:00
parent 4290daef43
commit ec33798c6c
7 changed files with 84 additions and 0 deletions

View File

@ -16,7 +16,9 @@
#include "jsondatamgr.h"
#include "handlermgr.h"
#include "gsmgr.h"
#include "imsmgr.h"
#include "GGListener.h"
#include "IMListener.h"
#include "ss_msgid.pb.h"
#include "ss_proto.pb.h"
@ -88,7 +90,9 @@ void App::Init(int argc, char* argv[])
JsonDataMgr::Instance()->Init();
uuid.SetMachineId(instance_id);
GGListener::Instance()->Init();
IMListener::Instance()->Init();
GSMgr::Instance()->Init();
IMSMgr::Instance()->Init();
a8::UdpLog::Instance()->Info("masterserver starting instance_id:%d pid:%d", {instance_id, getpid()});
{
@ -110,7 +114,9 @@ void App::UnInit()
if (terminated) {
return;
}
IMSMgr::Instance()->UnInit();
GSMgr::Instance()->UnInit();
IMListener::Instance()->UnInit();
GGListener::Instance()->UnInit();
JsonDataMgr::Instance()->UnInit();
f8::MsgQueue::Instance()->UnInit();
@ -303,6 +309,11 @@ void App::DispatchMsg()
ProcessGameGateMsg(hdr);
}
break;
case SF_IMServer:
{
ProcessIMServerMsg(hdr);
}
break;
}
if (pdelnode->buf) {
free(pdelnode->buf);
@ -332,6 +343,19 @@ void App::ProcessGameGateMsg(f8::MsgHdr& hdr)
}
}
void App::ProcessIMServerMsg(f8::MsgHdr& hdr)
{
f8::NetMsgHandler* handler = f8::GetNetMsgHandler(&HandlerMgr::Instance()->immsghandler,
hdr.msgid);
if (handler) {
switch (handler->handlerid) {
case HID_IMSMgr:
ProcessNetMsg(handler, IMSMgr::Instance(), hdr);
break;
}
}
}
void App::ProcessIMMsg()
{
if (!im_work_node_ && im_top_node_) {

View File

@ -43,6 +43,7 @@ private:
void ProcessIMMsg();
void ProcessGameGateMsg(f8::MsgHdr& hdr);
void ProcessIMServerMsg(f8::MsgHdr& hdr);
void InitLog();
void UnInitLog();

View File

@ -18,6 +18,7 @@ enum InnerMesssage_e
enum NetHandler_e
{
HID_GSMgr,
HID_IMSMgr,
};
const char* const PROJ_NAME_FMT = "friend_masterserver";

View File

@ -7,6 +7,7 @@
#include "GGListener.h"
#include "app.h"
#include "gsmgr.h"
#include "imsmgr.h"
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
{
@ -46,6 +47,9 @@ void HandlerMgr::UnInit()
void HandlerMgr::RegisterNetMsgHandlers()
{
RegisterNetMsgHandler(&ggmsghandler, &GSMgr::_SS_WSP_RequestTargetServer);
RegisterNetMsgHandler(&ggmsghandler, &GSMgr::_SS_Ping);
RegisterNetMsgHandler(&immsghandler, &IMSMgr::_SS_Ping);
}
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,

View File

@ -22,6 +22,7 @@ class HandlerMgr : public a8::Singleton<HandlerMgr>
void UnInit();
f8::NetMsgHandlerObject ggmsghandler;
f8::NetMsgHandlerObject immsghandler;
void ProcGMMsg(unsigned long saddr, int sockhandle,
const std::string& url, const std::string& quyerstr);

View File

@ -0,0 +1,28 @@
#include "precompile.h"
#include <a8/mutable_xobject.h>
#include <a8/timer.h>
#include "imsmgr.h"
#include "app.h"
#include "IMListener.h"
void IMSMgr::Init()
{
a8::Timer::Instance()->AddRepeatTimer(1000 * 2,
a8::XParams(),
[] (const a8::XParams& param)
{
});
}
void IMSMgr::UnInit()
{
}
void IMSMgr::_SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg)
{
ss::SS_Pong pongmsg;
IMListener::Instance()->SendMsg(hdr.socket_handle, pongmsg);
}

View File

@ -0,0 +1,25 @@
#pragma once
#include "ss_proto.pb.h"
class IMSMgr : public a8::Singleton<IMSMgr>
{
public:
enum { HID = HID_IMSMgr };
private:
IMSMgr() {};
friend class a8::Singleton<IMSMgr>;
public:
void Init();
void UnInit();
void _SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg);
private:
private:
};