This commit is contained in:
aozhiwei 2020-06-16 11:02:06 +08:00
parent 706268b524
commit d388471db0
5 changed files with 44 additions and 29 deletions

View File

@ -11,6 +11,8 @@
#include "jsondatamgr.h" #include "jsondatamgr.h"
#include "handlermgr.h" #include "handlermgr.h"
#include "ss_proto.pb.h"
class GGClientSession: public a8::MixedSession class GGClientSession: public a8::MixedSession
{ {
public: public:
@ -110,3 +112,9 @@ void GGListener::MarkClient(int sockhandle, bool is_active)
{ {
tcp_listener_->MarkClient(sockhandle, is_active); tcp_listener_->MarkClient(sockhandle, is_active);
} }
void GGListener::_SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg)
{
ss::SS_Pong pongmsg;
SendMsg(hdr.socket_handle, pongmsg);
}

View File

@ -6,8 +6,16 @@ namespace a8
class TcpListener; class TcpListener;
} }
namespace ss
{
class SS_Ping;
}
class GGListener : public a8::Singleton<GGListener> class GGListener : public a8::Singleton<GGListener>
{ {
public:
enum { HID = HID_SvrMgr };
private: private:
GGListener() {}; GGListener() {};
friend class a8::Singleton<GGListener>; friend class a8::Singleton<GGListener>;
@ -28,6 +36,8 @@ class GGListener : public a8::Singleton<GGListener>
void ForceCloseClient(int sockhandle); void ForceCloseClient(int sockhandle);
void MarkClient(int sockhandle, bool is_active); void MarkClient(int sockhandle, bool is_active);
void _SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg);
private: private:
a8::TcpListener *tcp_listener_ = nullptr; a8::TcpListener *tcp_listener_ = nullptr;
}; };

View File

@ -43,7 +43,8 @@ void HandlerMgr::UnInit()
void HandlerMgr::RegisterNetMsgHandlers() void HandlerMgr::RegisterNetMsgHandlers()
{ {
RegisterNetMsgHandler(&ggmsghandler, &SvrMgr::_SS_WSP_RequestTargetServer); RegisterNetMsgHandler(&ggmsghandler, &SvrMgr::_SS_WSP_RequestTargetServer);
RegisterNetMsgHandler(&ggmsghandler, &SvrMgr::_SS_Ping);
RegisterNetMsgHandler(&ggmsghandler, &GGListener::_SS_Ping);
RegisterNetMsgHandler(&immsghandler, &IMSMgr::_SS_Ping); RegisterNetMsgHandler(&immsghandler, &IMSMgr::_SS_Ping);
} }

View File

@ -38,12 +38,6 @@ void SvrMgr::_SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_Reque
GGListener::Instance()->SendMsg(hdr.socket_handle, respmsg); GGListener::Instance()->SendMsg(hdr.socket_handle, respmsg);
} }
void SvrMgr::_SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg)
{
ss::SS_Pong pongmsg;
GGListener::Instance()->SendMsg(hdr.socket_handle, pongmsg);
}
void SvrMgr::___GSList(f8::JsonHttpRequest* request) void SvrMgr::___GSList(f8::JsonHttpRequest* request)
{ {
{ {
@ -111,27 +105,30 @@ SvrNode* SvrMgr::AllocNode()
void SvrMgr::RearrangeNode() void SvrMgr::RearrangeNode()
{ {
std::sort(node_sorted_list_.begin(), node_sorted_list_.end(), std::sort
[] (const SvrNode* a, const SvrNode* b) (
{ node_sorted_list_.begin(),
if (a->servicing && b->servicing) { node_sorted_list_.end(),
if (a->online_num < b->online_num) { [] (const SvrNode* a, const SvrNode* b)
return true; {
} if (a->servicing && b->servicing) {
if (a->online_num > b->online_num) { if (a->online_num < b->online_num) {
return false; return true;
} }
return a->node_idx > b->node_idx; if (a->online_num > b->online_num) {
} return false;
if (a->servicing) { }
return true; return a->node_idx > b->node_idx;
} }
if (b->servicing) { if (a->servicing) {
return false; return true;
} }
return a->node_idx > b->node_idx; if (b->servicing) {
} return false;
); }
return a->node_idx > b->node_idx;
}
);
} }
void SvrMgr::ClearTimeOutNode() void SvrMgr::ClearTimeOutNode()

View File

@ -30,7 +30,6 @@ class SvrMgr : public a8::Singleton<SvrMgr>
void UnInit(); void UnInit();
void _SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_RequestTargetServer& msg); void _SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_RequestTargetServer& msg);
void _SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg);
void ___GSList(f8::JsonHttpRequest* request); void ___GSList(f8::JsonHttpRequest* request);