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 "handlermgr.h"
#include "ss_proto.pb.h"
class GGClientSession: public a8::MixedSession
{
public:
@ -110,3 +112,9 @@ void GGListener::MarkClient(int sockhandle, bool 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;
}
namespace ss
{
class SS_Ping;
}
class GGListener : public a8::Singleton<GGListener>
{
public:
enum { HID = HID_SvrMgr };
private:
GGListener() {};
friend class a8::Singleton<GGListener>;
@ -28,6 +36,8 @@ class GGListener : public a8::Singleton<GGListener>
void ForceCloseClient(int sockhandle);
void MarkClient(int sockhandle, bool is_active);
void _SS_Ping(f8::MsgHdr& hdr, const ss::SS_Ping& msg);
private:
a8::TcpListener *tcp_listener_ = nullptr;
};

View File

@ -43,7 +43,8 @@ void HandlerMgr::UnInit()
void HandlerMgr::RegisterNetMsgHandlers()
{
RegisterNetMsgHandler(&ggmsghandler, &SvrMgr::_SS_WSP_RequestTargetServer);
RegisterNetMsgHandler(&ggmsghandler, &SvrMgr::_SS_Ping);
RegisterNetMsgHandler(&ggmsghandler, &GGListener::_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);
}
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)
{
{
@ -111,27 +105,30 @@ SvrNode* SvrMgr::AllocNode()
void SvrMgr::RearrangeNode()
{
std::sort(node_sorted_list_.begin(), node_sorted_list_.end(),
[] (const SvrNode* a, const SvrNode* b)
{
if (a->servicing && b->servicing) {
if (a->online_num < b->online_num) {
return true;
}
if (a->online_num > b->online_num) {
return false;
}
return a->node_idx > b->node_idx;
}
if (a->servicing) {
return true;
}
if (b->servicing) {
return false;
}
return a->node_idx > b->node_idx;
}
);
std::sort
(
node_sorted_list_.begin(),
node_sorted_list_.end(),
[] (const SvrNode* a, const SvrNode* b)
{
if (a->servicing && b->servicing) {
if (a->online_num < b->online_num) {
return true;
}
if (a->online_num > b->online_num) {
return false;
}
return a->node_idx > b->node_idx;
}
if (a->servicing) {
return true;
}
if (b->servicing) {
return false;
}
return a->node_idx > b->node_idx;
}
);
}
void SvrMgr::ClearTimeOutNode()

View File

@ -30,7 +30,6 @@ class SvrMgr : public a8::Singleton<SvrMgr>
void UnInit();
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);