1
This commit is contained in:
parent
706268b524
commit
d388471db0
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user