diff --git a/server/tools/protobuild/ss_msgid.proto b/server/tools/protobuild/ss_msgid.proto index 7239b09..8a27991 100644 --- a/server/tools/protobuild/ss_msgid.proto +++ b/server/tools/protobuild/ss_msgid.proto @@ -13,6 +13,6 @@ enum SSMessageId_e _SS_CMPing = 101; _SS_SMRpcError = 102; _SS_CMLogin = 103; - _SS_CMReConnect = 104; + _SS_CMReconnect = 104; } diff --git a/server/tools/protobuild/ss_proto.proto b/server/tools/protobuild/ss_proto.proto index 8a7ebcb..2f96110 100644 --- a/server/tools/protobuild/ss_proto.proto +++ b/server/tools/protobuild/ss_proto.proto @@ -13,7 +13,14 @@ message SS_CMLogin_CMReConnect_CommonHead optional int32 server_id = 1; } -message SS_CMLogin_CMReConnect_CommonHead2 +message SS_CMLogin +{ + optional int32 server_id = 1; //保留 + optional string team_uuid = 2; //保留 + optional string account_id = 3; //账号id +} + +message SS_CMReconnect { optional int32 server_id = 1; //保留 optional string team_uuid = 2; //保留 @@ -28,6 +35,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 diff --git a/server/wsproxy/app.cc b/server/wsproxy/app.cc index d933a15..63ad213 100644 --- a/server/wsproxy/app.cc +++ b/server/wsproxy/app.cc @@ -422,11 +422,42 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr) return; } #if MASTER_MODE - if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReConnect) { - ss::SS_CMLogin_CMReConnect_CommonHead2 msg; - bool ok = msg.ParseFromArray(hdr.buf + hdr.offset, hdr.buflen - hdr.offset); - if (ok) { - MasterSvrMgr::Instance()->RequestTargetServer(hdr, msg.team_uuid(), msg.account_id()); + if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReconnect) { + GameClient* client = GameClientMgr::Instance()->GetGameClientBySocket(hdr.socket_handle); + if (!client) { + switch (hdr.msgid) { + case ss::_SS_CMLogin: + { + ss::SS_CMLogin msg; + bool ok = msg.ParseFromArray(hdr.buf + hdr.offset, hdr.buflen - hdr.offset); + if (ok) { + MasterSvrMgr::Instance()->RequestTargetServer(hdr, + msg.team_uuid(), + msg.account_id(), + "", + 0); + } + } + break; + case ss::_SS_CMReconnect: + { + ss::SS_CMReconnect msg; + bool ok = msg.ParseFromArray(hdr.buf + hdr.offset, hdr.buflen - hdr.offset); + if (ok) { + MasterSvrMgr::Instance()->RequestTargetServer(hdr, + msg.team_uuid(), + msg.account_id(), + "", + 1); + } + } + break; + default: + { + abort(); + } + break; + } } } else { GameClient* client = GameClientMgr::Instance()->GetGameClientBySocket(hdr.socket_handle); @@ -487,7 +518,7 @@ void App::ProcessTargetServerMsg(f8::MsgHdr& hdr) if (hdr.msgid < 100) { return; } - if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReConnect) { + if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReconnect) { GameClientMgr::Instance()->BindTargetConn(hdr.socket_handle, hdr.ip_saddr); GCListener::Instance()->MarkClient(hdr.socket_handle, true); } diff --git a/server/wsproxy/mastersvrmgr.cc b/server/wsproxy/mastersvrmgr.cc index a501985..67fb647 100644 --- a/server/wsproxy/mastersvrmgr.cc +++ b/server/wsproxy/mastersvrmgr.cc @@ -68,7 +68,11 @@ MasterSvr* MasterSvrMgr::GetConnById(int instance_id) return itr != mastersvr_hash_.end() ? itr->second : nullptr; } -void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_id, const std::string& account_id) +void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, + const std::string& team_id, + const std::string& account_id, + const std::string& server_info, + int is_reconnect) { #if GAME_ID == 9003 { @@ -113,6 +117,8 @@ void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_ ss::SS_WSP_RequestTargetServer msg; msg.set_context_id(curr_context_id_); msg.set_team_id(team_uuid); + msg.set_server_info(server_info); + msg.set_is_reconnect(is_reconnect); svr->SendMsg(msg); pending_socket_hash_[hdr.socket_handle] = curr_context_id_; diff --git a/server/wsproxy/mastersvrmgr.h b/server/wsproxy/mastersvrmgr.h index a6c14ed..17ce7a0 100644 --- a/server/wsproxy/mastersvrmgr.h +++ b/server/wsproxy/mastersvrmgr.h @@ -26,7 +26,11 @@ class MasterSvrMgr : public a8::Singleton 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, const std::string& account_id); + void RequestTargetServer(f8::MsgHdr& hdr, + const std::string& team_id, + const std::string& account_id, + const std::string& server_info, + int is_reconnect); void RemoveRequest(int socket_handle, long long context_id, bool auto_free); private: