add imsmgr
This commit is contained in:
parent
4290daef43
commit
ec33798c6c
@ -16,7 +16,9 @@
|
|||||||
#include "jsondatamgr.h"
|
#include "jsondatamgr.h"
|
||||||
#include "handlermgr.h"
|
#include "handlermgr.h"
|
||||||
#include "gsmgr.h"
|
#include "gsmgr.h"
|
||||||
|
#include "imsmgr.h"
|
||||||
#include "GGListener.h"
|
#include "GGListener.h"
|
||||||
|
#include "IMListener.h"
|
||||||
|
|
||||||
#include "ss_msgid.pb.h"
|
#include "ss_msgid.pb.h"
|
||||||
#include "ss_proto.pb.h"
|
#include "ss_proto.pb.h"
|
||||||
@ -88,7 +90,9 @@ void App::Init(int argc, char* argv[])
|
|||||||
JsonDataMgr::Instance()->Init();
|
JsonDataMgr::Instance()->Init();
|
||||||
uuid.SetMachineId(instance_id);
|
uuid.SetMachineId(instance_id);
|
||||||
GGListener::Instance()->Init();
|
GGListener::Instance()->Init();
|
||||||
|
IMListener::Instance()->Init();
|
||||||
GSMgr::Instance()->Init();
|
GSMgr::Instance()->Init();
|
||||||
|
IMSMgr::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()});
|
||||||
{
|
{
|
||||||
@ -110,7 +114,9 @@ void App::UnInit()
|
|||||||
if (terminated) {
|
if (terminated) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
IMSMgr::Instance()->UnInit();
|
||||||
GSMgr::Instance()->UnInit();
|
GSMgr::Instance()->UnInit();
|
||||||
|
IMListener::Instance()->UnInit();
|
||||||
GGListener::Instance()->UnInit();
|
GGListener::Instance()->UnInit();
|
||||||
JsonDataMgr::Instance()->UnInit();
|
JsonDataMgr::Instance()->UnInit();
|
||||||
f8::MsgQueue::Instance()->UnInit();
|
f8::MsgQueue::Instance()->UnInit();
|
||||||
@ -303,6 +309,11 @@ void App::DispatchMsg()
|
|||||||
ProcessGameGateMsg(hdr);
|
ProcessGameGateMsg(hdr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SF_IMServer:
|
||||||
|
{
|
||||||
|
ProcessIMServerMsg(hdr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (pdelnode->buf) {
|
if (pdelnode->buf) {
|
||||||
free(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()
|
void App::ProcessIMMsg()
|
||||||
{
|
{
|
||||||
if (!im_work_node_ && im_top_node_) {
|
if (!im_work_node_ && im_top_node_) {
|
||||||
|
@ -43,6 +43,7 @@ private:
|
|||||||
void ProcessIMMsg();
|
void ProcessIMMsg();
|
||||||
|
|
||||||
void ProcessGameGateMsg(f8::MsgHdr& hdr);
|
void ProcessGameGateMsg(f8::MsgHdr& hdr);
|
||||||
|
void ProcessIMServerMsg(f8::MsgHdr& hdr);
|
||||||
|
|
||||||
void InitLog();
|
void InitLog();
|
||||||
void UnInitLog();
|
void UnInitLog();
|
||||||
|
@ -18,6 +18,7 @@ enum InnerMesssage_e
|
|||||||
enum NetHandler_e
|
enum NetHandler_e
|
||||||
{
|
{
|
||||||
HID_GSMgr,
|
HID_GSMgr,
|
||||||
|
HID_IMSMgr,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* const PROJ_NAME_FMT = "friend_masterserver";
|
const char* const PROJ_NAME_FMT = "friend_masterserver";
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "GGListener.h"
|
#include "GGListener.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "gsmgr.h"
|
#include "gsmgr.h"
|
||||||
|
#include "imsmgr.h"
|
||||||
|
|
||||||
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
||||||
{
|
{
|
||||||
@ -46,6 +47,9 @@ void HandlerMgr::UnInit()
|
|||||||
void HandlerMgr::RegisterNetMsgHandlers()
|
void HandlerMgr::RegisterNetMsgHandlers()
|
||||||
{
|
{
|
||||||
RegisterNetMsgHandler(&ggmsghandler, &GSMgr::_SS_WSP_RequestTargetServer);
|
RegisterNetMsgHandler(&ggmsghandler, &GSMgr::_SS_WSP_RequestTargetServer);
|
||||||
|
RegisterNetMsgHandler(&ggmsghandler, &GSMgr::_SS_Ping);
|
||||||
|
|
||||||
|
RegisterNetMsgHandler(&immsghandler, &IMSMgr::_SS_Ping);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
||||||
|
@ -22,6 +22,7 @@ class HandlerMgr : public a8::Singleton<HandlerMgr>
|
|||||||
void UnInit();
|
void UnInit();
|
||||||
|
|
||||||
f8::NetMsgHandlerObject ggmsghandler;
|
f8::NetMsgHandlerObject ggmsghandler;
|
||||||
|
f8::NetMsgHandlerObject immsghandler;
|
||||||
|
|
||||||
void ProcGMMsg(unsigned long saddr, int sockhandle,
|
void ProcGMMsg(unsigned long saddr, int sockhandle,
|
||||||
const std::string& url, const std::string& quyerstr);
|
const std::string& url, const std::string& quyerstr);
|
||||||
|
28
server/masterserver/imsmgr.cc
Normal file
28
server/masterserver/imsmgr.cc
Normal 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);
|
||||||
|
}
|
25
server/masterserver/imsmgr.h
Normal file
25
server/masterserver/imsmgr.h
Normal 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:
|
||||||
|
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user