Skip to content

Commit

Permalink
新增加消息中心服务
Browse files Browse the repository at this point in the history
新增加消息中心服务,支持消息转发、用户位置查询、用户消息转发等等
  • Loading branch information
limingfan2016 committed Mar 4, 2018
1 parent 6ee9536 commit d9026a1
Show file tree
Hide file tree
Showing 9 changed files with 1,342 additions and 0 deletions.
40 changes: 40 additions & 0 deletions message_center/BaseDefine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

/* author : limingfan
* date : 2017.09.18
* description : 基础类型定义
*/

#ifndef __BASE_DEFINE_H__
#define __BASE_DEFINE_H__

#include "../common/MessageCenterProtocolId.h"
#include "../common/MessageCenterErrorCode.h"
#include "../common/CommonType.h"
#include "../common/CServiceOperation.h"
#include "../common/OperationManagerProtocolId.h"
#include "../common/DBProxyProtocolId.h"

#include "_MsgCenterCfg_.h"
#include "protocol/appsrv_message_center.pb.h"


using namespace NProject;

typedef unordered_map<string, unsigned int> UserNameToServiceID;

// 大厅、棋牌室信息
struct SHallInfo
{
unsigned int serviceId;
string hallId;

SHallInfo() {};
SHallInfo(unsigned int srvId, const string& hId) : serviceId(srvId), hallId(hId) {};
~SHallInfo() {};
};

typedef unordered_map<string, SHallInfo> UserNameToHallInfo;


#endif // __BASE_DEFINE_H__

54 changes: 54 additions & 0 deletions message_center/CMessageSrvFrame.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

/* author : liuxu
* date : 2015.04.28
* description : 消息中心服务框架代码
*/

#include "CMessageSrvFrame.h"
#include "CMsgCenterHandler.h"


using namespace NCommon;
using namespace NFrame;


int CMessageSrvFrame::onInit(const char* name, const unsigned int id)
{
ReleaseInfoLog("--- onInit service ---, name = %s, id = %d", name, id);
return 0;
}

void CMessageSrvFrame::onUnInit(const char* name, const unsigned int id)
{
ReleaseInfoLog("--- onUnInit service ---, name = %s, id = %d", name, id);
}

void CMessageSrvFrame::onRegister(const char* name, const unsigned int id)
{
ReleaseInfoLog("--- onRegister module ---, name = %s, id = %d", name, id);

// 注册模块实例
static CMsgCenterHandler handler1;
m_pMsgHandler = &handler1;
registerModule(0, &handler1);
}

void CMessageSrvFrame::onUpdateConfig(const char* name, const unsigned int id)
{
m_pMsgHandler->loadConfig(true);
}


CMessageSrvFrame::CMessageSrvFrame() :IService::IService(ServiceType::MessageCenterSrv)
{

}

CMessageSrvFrame::~CMessageSrvFrame()
{
}


REGISTER_SERVICE(CMessageSrvFrame);


32 changes: 32 additions & 0 deletions message_center/CMessageSrvFrame.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

/* author : liuxu
* date : 2015.04.28
* description : 消息中心服务框架代码
*/

#ifndef __CMESSAGE_SVR_FRAME_H__
#define __CMESSAGE_SVR_FRAME_H__

#include "SrvFrame/IService.h"


class CMsgCenterHandler;


class CMessageSrvFrame : public NFrame::IService
{
public:
CMessageSrvFrame();
~CMessageSrvFrame();

public:
virtual int onInit(const char* name, const unsigned int id); // 服务启动时被调用
virtual void onUnInit(const char* name, const unsigned int id); // 服务停止时被调用
virtual void onRegister(const char* name, const unsigned int id); // 服务启动后被调用,服务需在此注册本服务的各模块信息
virtual void onUpdateConfig(const char* name, const unsigned int id); // 服务配置更新

private:
CMsgCenterHandler* m_pMsgHandler;
};

#endif // __CMESSAGE_SVR_FRAME_H__
Loading

0 comments on commit d9026a1

Please sign in to comment.