完成dbproxy逻辑
This commit is contained in:
parent
7ca0b59845
commit
de22262a6c
@ -17,6 +17,7 @@
|
|||||||
#include "handlermgr.h"
|
#include "handlermgr.h"
|
||||||
#include "ss_msgid.pb.h"
|
#include "ss_msgid.pb.h"
|
||||||
#include "ss_proto.pb.h"
|
#include "ss_proto.pb.h"
|
||||||
|
#include "dbpool.h"
|
||||||
|
|
||||||
struct MsgNode
|
struct MsgNode
|
||||||
{
|
{
|
||||||
@ -83,6 +84,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();
|
||||||
|
DBPool::Instance()->Init();
|
||||||
GSListener::Instance()->Init();
|
GSListener::Instance()->Init();
|
||||||
uuid.SetMachineId(instance_id);
|
uuid.SetMachineId(instance_id);
|
||||||
|
|
||||||
@ -107,6 +109,7 @@ void App::UnInit()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GSListener::Instance()->UnInit();
|
GSListener::Instance()->UnInit();
|
||||||
|
DBPool::Instance()->UnInit();
|
||||||
JsonDataMgr::Instance()->UnInit();
|
JsonDataMgr::Instance()->UnInit();
|
||||||
a8::Timer::Instance()->UnInit();
|
a8::Timer::Instance()->UnInit();
|
||||||
HandlerMgr::Instance()->UnInit();
|
HandlerMgr::Instance()->UnInit();
|
||||||
@ -279,6 +282,13 @@ 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;
|
||||||
|
switch (pdelnode->sockfrom) {
|
||||||
|
case SF_GameServer:
|
||||||
|
{
|
||||||
|
ProcessGSMsg(hdr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (pdelnode->buf) {
|
if (pdelnode->buf) {
|
||||||
free(pdelnode->buf);
|
free(pdelnode->buf);
|
||||||
}
|
}
|
||||||
@ -294,17 +304,21 @@ void App::DispatchMsg()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::ProcessClientMsg(MsgHdr& hdr)
|
void App::ProcessGSMsg(MsgHdr& hdr)
|
||||||
{
|
{
|
||||||
if (hdr.msgid < 100) {
|
NetMsgHandler* handler = GetNetMsgHandler(&HandlerMgr::Instance()->gsmsghandler,
|
||||||
return;
|
hdr.msgid);
|
||||||
|
if (handler) {
|
||||||
|
switch (handler->handlerid) {
|
||||||
|
case HID_DBPool:
|
||||||
|
{
|
||||||
|
ProcessNetMsg(handler, DBPool::Instance(), hdr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::ProcessTargetServerMsg(MsgHdr& hdr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::ProcessIMMsg()
|
void App::ProcessIMMsg()
|
||||||
{
|
{
|
||||||
if (!im_work_node_ && im_top_node_) {
|
if (!im_work_node_ && im_top_node_) {
|
||||||
|
@ -41,8 +41,7 @@ private:
|
|||||||
void DispatchMsg();
|
void DispatchMsg();
|
||||||
void ProcessIMMsg();
|
void ProcessIMMsg();
|
||||||
|
|
||||||
void ProcessClientMsg(MsgHdr& hdr);
|
void ProcessGSMsg(MsgHdr& hdr);
|
||||||
void ProcessTargetServerMsg(MsgHdr& hdr);
|
|
||||||
|
|
||||||
void InitLog();
|
void InitLog();
|
||||||
void UnInitLog();
|
void UnInitLog();
|
||||||
|
@ -7,8 +7,12 @@ namespace ss
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DBThread;
|
class DBThread;
|
||||||
class DBPool
|
class DBPool : public a8::Singleton<DBPool>
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
DBPool() {};
|
||||||
|
friend class a8::Singleton<DBPool>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { HID = HID_DBPool };
|
enum { HID = HID_DBPool };
|
||||||
|
|
||||||
@ -26,4 +30,3 @@ class DBPool
|
|||||||
DBThread* db_single_thread_ = nullptr;
|
DBThread* db_single_thread_ = nullptr;
|
||||||
std::vector<DBThread*> db_thread_pool_;
|
std::vector<DBThread*> db_thread_pool_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
#include <a8/mutable_xobject.h>
|
#include <a8/mutable_xobject.h>
|
||||||
|
|
||||||
#include "handlermgr.h"
|
#include "handlermgr.h"
|
||||||
|
|
||||||
#include "GSListener.h"
|
#include "GSListener.h"
|
||||||
|
#include "dbpool.h"
|
||||||
|
#include "ss_proto.pb.h"
|
||||||
|
|
||||||
void _GMAppEcho(a8::HTTPRequest& request, a8::MutableXObject* xobj)
|
void _GMAppEcho(a8::HTTPRequest& request, a8::MutableXObject* xobj)
|
||||||
{
|
{
|
||||||
@ -25,6 +26,8 @@ void HandlerMgr::UnInit()
|
|||||||
|
|
||||||
void HandlerMgr::RegisterNetMsgHandlers()
|
void HandlerMgr::RegisterNetMsgHandlers()
|
||||||
{
|
{
|
||||||
|
RegisterNetMsgHandler(&gsmsghandler, &DBPool::_SS_Ping);
|
||||||
|
RegisterNetMsgHandler(&gsmsghandler, &DBPool::_SS_GSM_ExecAsyncSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlerMgr::ProcGMMsg(int sockhandle, const std::string& url, const std::string& querystr)
|
void HandlerMgr::ProcGMMsg(int sockhandle, const std::string& url, const std::string& querystr)
|
||||||
|
@ -21,8 +21,6 @@ class HandlerMgr : public a8::Singleton<HandlerMgr>
|
|||||||
void Init();
|
void Init();
|
||||||
void UnInit();
|
void UnInit();
|
||||||
|
|
||||||
NetMsgHandlerObject gcmsghandler;
|
|
||||||
NetMsgHandlerObject rsmsghandler;
|
|
||||||
NetMsgHandlerObject gsmsghandler;
|
NetMsgHandlerObject gsmsghandler;
|
||||||
|
|
||||||
void ProcGMMsg(int sockhandle, const std::string& url, const std::string& quyerstr);
|
void ProcGMMsg(int sockhandle, const std::string& url, const std::string& quyerstr);
|
||||||
|
@ -3,8 +3,8 @@ package ss;
|
|||||||
//消息id定义
|
//消息id定义
|
||||||
enum SSMessageId_e
|
enum SSMessageId_e
|
||||||
{
|
{
|
||||||
_SS_Ping = 150;
|
_SS_Ping = 100;
|
||||||
_SS_Pong = 151;
|
_SS_Pong = 101;
|
||||||
_SS_GSM_ExecAsyncSql = 152;
|
_SS_GSM_ExecAsyncSql = 152;
|
||||||
_SS_DPM_ExecAsyncSql = 153;
|
_SS_DPM_ExecAsyncSql = 153;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user