From d388471db042f0fccbb066250f3f0c4024498560 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 16 Jun 2020 11:02:06 +0800 Subject: [PATCH] 1 --- server/masterserver/GGListener.cc | 8 +++++ server/masterserver/GGListener.h | 10 ++++++ server/masterserver/handlermgr.cc | 3 +- server/masterserver/svrmgr.cc | 51 +++++++++++++++---------------- server/masterserver/svrmgr.h | 1 - 5 files changed, 44 insertions(+), 29 deletions(-) diff --git a/server/masterserver/GGListener.cc b/server/masterserver/GGListener.cc index 8529711..c837809 100644 --- a/server/masterserver/GGListener.cc +++ b/server/masterserver/GGListener.cc @@ -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); +} diff --git a/server/masterserver/GGListener.h b/server/masterserver/GGListener.h index 817dde2..929c625 100644 --- a/server/masterserver/GGListener.h +++ b/server/masterserver/GGListener.h @@ -6,8 +6,16 @@ namespace a8 class TcpListener; } +namespace ss +{ + class SS_Ping; +} + class GGListener : public a8::Singleton { + public: + enum { HID = HID_SvrMgr }; + private: GGListener() {}; friend class a8::Singleton; @@ -28,6 +36,8 @@ class GGListener : public a8::Singleton 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; }; diff --git a/server/masterserver/handlermgr.cc b/server/masterserver/handlermgr.cc index a94f9b9..81d6c59 100644 --- a/server/masterserver/handlermgr.cc +++ b/server/masterserver/handlermgr.cc @@ -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); } diff --git a/server/masterserver/svrmgr.cc b/server/masterserver/svrmgr.cc index 566df94..aae719b 100644 --- a/server/masterserver/svrmgr.cc +++ b/server/masterserver/svrmgr.cc @@ -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() diff --git a/server/masterserver/svrmgr.h b/server/masterserver/svrmgr.h index cc6b30d..859b51a 100644 --- a/server/masterserver/svrmgr.h +++ b/server/masterserver/svrmgr.h @@ -30,7 +30,6 @@ class SvrMgr : public a8::Singleton 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);