61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "ss_proto.pb.h"
|
|
|
|
struct SvrNode
|
|
{
|
|
std::string key;
|
|
int socket_handle = 0;
|
|
long long node_idx = 0;
|
|
int instance_id = 0;
|
|
int online_num = 0;
|
|
std::string ip;
|
|
int port = 0;
|
|
bool servicing = false;
|
|
long long last_active_tick = 0;
|
|
|
|
list_head human_list;
|
|
|
|
SvrNode()
|
|
{
|
|
INIT_LIST_HEAD(&human_list);
|
|
}
|
|
};
|
|
|
|
class SvrMgr : public a8::Singleton<SvrMgr>
|
|
{
|
|
public:
|
|
enum { HID = HID_SvrMgr };
|
|
|
|
private:
|
|
SvrMgr() {};
|
|
friend class a8::Singleton<SvrMgr>;
|
|
|
|
public:
|
|
|
|
void Init();
|
|
void UnInit();
|
|
|
|
void _SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_RequestTargetServer& msg);
|
|
void _SS_IM_ReportServerInfo(f8::MsgHdr& hdr, const ss::SS_IM_ReportServerInfo& msg);
|
|
void _SS_IM_IMServerList(f8::MsgHdr& hdr, const ss::SS_IM_IMServerList& msg);
|
|
|
|
void ___GSList(f8::JsonHttpRequest* request);
|
|
|
|
SvrNode* GetNodeBySocket(int socket_handle);
|
|
void OnIMServerDisconnect(a8::XParams& param);
|
|
|
|
private:
|
|
SvrNode* AllocNode(const std::string& account_id);
|
|
void RearrangeNode();
|
|
void ClearTimeOutNode();
|
|
SvrNode* GetNodeByKey(const std::string& key);
|
|
void RemoveNode(SvrNode* node);
|
|
|
|
private:
|
|
|
|
std::map<std::string, SvrNode*> node_key_hash_;
|
|
std::map<int, SvrNode*> socket_hash_;
|
|
std::vector<SvrNode*> node_sorted_list_;
|
|
};
|