添加断线重连逻辑处理

This commit is contained in:
aozhiwei 2020-08-10 16:26:56 +08:00
parent 73dce8fc5a
commit 668074da06
3 changed files with 27 additions and 7 deletions

View File

@ -26,6 +26,16 @@ void GSMgr::_SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_Reques
{
ss::SS_MS_ResponseTargetServer respmsg;
respmsg.set_context_id(msg.context_id());
if (msg.is_reconnect()) {
GSNode* node = GetNodeByNodeKey(msg.server_info());
if (node) {
respmsg.set_host(node->ip);
respmsg.set_port(node->port);
} else {
respmsg.set_error_code(1);
respmsg.set_error_msg("无法分配节点");
}
} else {
GSNode* node = GetNodeByTeamId(msg.team_id());
if (node) {
respmsg.set_host(node->ip);
@ -41,6 +51,7 @@ void GSMgr::_SS_WSP_RequestTargetServer(f8::MsgHdr& hdr, const ss::SS_WSP_Reques
respmsg.set_error_msg("无法分配节点");
}
}
}
GGListener::Instance()->SendMsg(hdr.socket_handle, respmsg);
}
@ -151,6 +162,12 @@ GSNode* GSMgr::GetNodeByTeamId(const std::string& team_id)
return itr != team_hash_.end() ? itr->second : nullptr;
}
GSNode* GSMgr::GetNodeByNodeKey(const std::string& node_key)
{
auto itr = node_key_hash_.find(node_key);
return itr != node_key_hash_.end() ? &itr->second : nullptr;
}
GSNode* GSMgr::AllocNode()
{
if (node_sorted_list_.empty()) {

View File

@ -39,6 +39,7 @@ class GSMgr : public a8::Singleton<GSMgr>
private:
GSNode* GetNodeByTeamId(const std::string& team_id);
GSNode* GetNodeByNodeKey(const std::string& node_key);
GSNode* AllocNode();
void RearrangeNode();
void ClearTimeOutNode();

View File

@ -19,6 +19,8 @@ message SS_WSP_RequestTargetServer
optional int64 context_id = 1;
optional string account_id = 2;
optional string team_id = 3;
optional string server_info = 4;
optional int32 is_reconnect = 5;
}
message SS_MS_ResponseTargetServer