From 0442ea3ecefa5dbc7242d8dc64ab9e3ed876fea8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 15 May 2019 17:55:47 +0800 Subject: [PATCH] 1 --- server/wsproxy/constant.h | 4 +--- server/wsproxy/handlermgr.cc | 4 ++++ server/wsproxy/handlermgr.h | 3 +-- server/wsproxy/mastersvrmgr.cc | 19 ++++++++++++++++++- server/wsproxy/mastersvrmgr.h | 9 +++++++++ server/wsproxy/target_conn_mgr.cc | 5 +++++ server/wsproxy/target_conn_mgr.h | 2 ++ 7 files changed, 40 insertions(+), 6 deletions(-) diff --git a/server/wsproxy/constant.h b/server/wsproxy/constant.h index cb07ea9..3c28b59 100644 --- a/server/wsproxy/constant.h +++ b/server/wsproxy/constant.h @@ -19,10 +19,8 @@ enum InnerMesssage_e //网络处理对象 enum NetHandler_e { - HID_Player, - HID_PlayerMgr, - HID_RoomSvrMgr, HID_GCListener, + HID_MasterSvrMgr, }; enum PlayerState_e diff --git a/server/wsproxy/handlermgr.cc b/server/wsproxy/handlermgr.cc index 7608c93..02f368c 100644 --- a/server/wsproxy/handlermgr.cc +++ b/server/wsproxy/handlermgr.cc @@ -5,6 +5,9 @@ #include "handlermgr.h" #include "GCListener.h" +#include "mastersvrmgr.h" + +#include "ss_proto.pb.h" static void _GMOpsSelfChecking(f8::JsonHttpRequest* request) { @@ -26,6 +29,7 @@ void HandlerMgr::UnInit() void HandlerMgr::RegisterNetMsgHandlers() { + RegisterNetMsgHandler(&msmsghandler, &MasterSvrMgr::_SS_MS_ResponseTargetServer); } void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle, diff --git a/server/wsproxy/handlermgr.h b/server/wsproxy/handlermgr.h index 4e92981..6f5fab6 100644 --- a/server/wsproxy/handlermgr.h +++ b/server/wsproxy/handlermgr.h @@ -22,8 +22,7 @@ class HandlerMgr : public a8::Singleton void UnInit(); f8::NetMsgHandlerObject gcmsghandler; - f8::NetMsgHandlerObject rsmsghandler; - f8::NetMsgHandlerObject gsmsghandler; + f8::NetMsgHandlerObject msmsghandler; void ProcGMMsg(unsigned long saddr, int sockhandle, const std::string& url, const std::string& querystr); diff --git a/server/wsproxy/mastersvrmgr.cc b/server/wsproxy/mastersvrmgr.cc index 710cea6..5ca2d08 100644 --- a/server/wsproxy/mastersvrmgr.cc +++ b/server/wsproxy/mastersvrmgr.cc @@ -32,6 +32,23 @@ void MasterSvrMgr::UnInit() { } +void MasterSvrMgr::_SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_ResponseTargetServer& msg) +{ + f8::MsgHdr* context_hdr = GetHdr(msg.context_id()); + if (context_hdr) { + if (msg.error_code() == 0) { + + } + + pending_request_hash_.erase(msg.context_id()); + pending_socket_hash_.erase(hdr.socket_handle); + if (context_hdr->buf) { + free((char*)context_hdr->buf); + } + free(context_hdr); + } +} + MasterSvr* MasterSvrMgr::GetConnByInstanceId(int instance_id) { auto itr = mastersvr_hash_.find(instance_id); @@ -66,7 +83,7 @@ void MasterSvrMgr::OnClientDisconnect(a8::XParams& param) if (hdr->buf) { free((char*)hdr->buf); } - delete hdr; + free(hdr); pending_request_hash_.erase(conext_id); } pending_socket_hash_.erase(param.sender); diff --git a/server/wsproxy/mastersvrmgr.h b/server/wsproxy/mastersvrmgr.h index 9373e6a..8c657c1 100644 --- a/server/wsproxy/mastersvrmgr.h +++ b/server/wsproxy/mastersvrmgr.h @@ -5,9 +5,17 @@ namespace f8 struct MsgHdr; } +namespace ss +{ + class SS_MS_ResponseTargetServer; +} + class MasterSvr; class MasterSvrMgr : public a8::Singleton { + public: + enum { HID = HID_MasterSvrMgr }; + private: MasterSvrMgr() {}; friend class a8::Singleton; @@ -17,6 +25,7 @@ class MasterSvrMgr : public a8::Singleton void Init(); void UnInit(); + void _SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_ResponseTargetServer& msg); void RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_id); void OnClientDisconnect(a8::XParams& param); diff --git a/server/wsproxy/target_conn_mgr.cc b/server/wsproxy/target_conn_mgr.cc index 3fbbf00..50ae376 100644 --- a/server/wsproxy/target_conn_mgr.cc +++ b/server/wsproxy/target_conn_mgr.cc @@ -29,6 +29,11 @@ void TargetConnMgr::UnInit() } #if MASTER_MODE +TargetConn* TargetConnMgr::GetConnByKey(const std::string& key) +{ + auto itr = target_conn_hash_.find(key); + return itr != target_conn_hash_.end() ? itr->second : nullptr; +} #else TargetConn* TargetConnMgr::GetConnByInstanceId(int instance_id) { diff --git a/server/wsproxy/target_conn_mgr.h b/server/wsproxy/target_conn_mgr.h index 0f7aa9c..f2c96d2 100644 --- a/server/wsproxy/target_conn_mgr.h +++ b/server/wsproxy/target_conn_mgr.h @@ -13,6 +13,7 @@ class TargetConnMgr : public a8::Singleton void UnInit(); #if MASTER_MODE + TargetConn* GetConnByKey(const std::string& key); #else TargetConn* GetConnByInstanceId(int instance_id); #endif @@ -20,6 +21,7 @@ class TargetConnMgr : public a8::Singleton private: #if MASTER_MODE + std::map target_conn_hash_; #else std::map target_conn_hash_; #endif