This commit is contained in:
aozhiwei 2019-06-05 16:10:39 +08:00
parent 275709d03a
commit a6c8f4c85d
5 changed files with 16 additions and 9 deletions

View File

@ -17,6 +17,7 @@ message SS_CMLogin_CMReConnect_CommonHead2
{ {
optional int32 server_id = 1; optional int32 server_id = 1;
optional string team_uuid = 2; optional string team_uuid = 2;
optional string account_id = 3;
} }
message SS_WSP_RequestTargetServer message SS_WSP_RequestTargetServer

View File

@ -382,7 +382,7 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr)
ss::SS_CMLogin_CMReConnect_CommonHead2 msg; ss::SS_CMLogin_CMReConnect_CommonHead2 msg;
bool ok = msg.ParseFromArray(hdr.buf + hdr.offset, hdr.buflen - hdr.offset); bool ok = msg.ParseFromArray(hdr.buf + hdr.offset, hdr.buflen - hdr.offset);
if (ok) { if (ok) {
MasterSvrMgr::Instance()->RequestTargetServer(hdr, msg.team_uuid()); MasterSvrMgr::Instance()->RequestTargetServer(hdr, msg.team_uuid(), msg.account_id());
} }
} else { } else {
GameClient* client = GameClientMgr::Instance()->GetGameClientBySocket(hdr.socket_handle); GameClient* client = GameClientMgr::Instance()->GetGameClientBySocket(hdr.socket_handle);
@ -626,4 +626,3 @@ void App::FreeIMMsgQueue()
} }
im_msg_mutex_->unlock(); im_msg_mutex_->unlock();
} }

View File

@ -1,5 +1,7 @@
#include "precompile.h" #include "precompile.h"
#include <unistd.h>
#include <a8/openssl.h> #include <a8/openssl.h>
#include <a8/timer.h> #include <a8/timer.h>
@ -64,17 +66,19 @@ MasterSvr* MasterSvrMgr::GetConnById(int instance_id)
return itr != mastersvr_hash_.end() ? itr->second : nullptr; return itr != mastersvr_hash_.end() ? itr->second : nullptr;
} }
void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_id) void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_id, const std::string& account_id)
{ {
if (GetContextIdBySocket(hdr.socket_handle) != 0) { if (GetContextIdBySocket(hdr.socket_handle) != 0) {
return; return;
} }
unsigned int code = a8::openssl::Crc32((unsigned char*)team_id.data(), team_id.size()); unsigned int code = 0;
#if 1 if (!team_id.empty()) {
MasterSvr* svr = GetConnById(2); code = a8::openssl::Crc32((unsigned char*)team_id.data(), team_id.size());
#else } else {
std::string data = a8::Format("!%s_%s_%d", {account_id, App::Instance()->uuid.Generate(), getpid()});
code = a8::openssl::Crc32((unsigned char*)data.data(), data.size());
}
MasterSvr* svr = GetConnById(code % mastersvr_hash_.size() + 1); MasterSvr* svr = GetConnById(code % mastersvr_hash_.size() + 1);
#endif
if (svr) { if (svr) {
++curr_context_id_; ++curr_context_id_;
a8::TimerAttacher* timer_attacher = new a8::TimerAttacher(); a8::TimerAttacher* timer_attacher = new a8::TimerAttacher();

View File

@ -26,7 +26,7 @@ class MasterSvrMgr : public a8::Singleton<MasterSvrMgr>
void UnInit(); void UnInit();
void _SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_ResponseTargetServer& msg); void _SS_MS_ResponseTargetServer(f8::MsgHdr& hdr, const ss::SS_MS_ResponseTargetServer& msg);
void RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_id); void RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_id, const std::string& account_id);
void RemoveRequest(int socket_handle, long long context_id, bool auto_free); void RemoveRequest(int socket_handle, long long context_id, bool auto_free);
private: private:

View File

@ -14,6 +14,9 @@ const int PACK_MAX = 1024 * 64 * 2;
void TargetConn::Init(int instance_id, const std::string& remote_ip, int remote_port) void TargetConn::Init(int instance_id, const std::string& remote_ip, int remote_port)
{ {
if (remote_ip.empty()) {
abort();
}
this->instance_id = instance_id; this->instance_id = instance_id;
this->remote_ip = remote_ip; this->remote_ip = remote_ip;
this->remote_port = remote_port; this->remote_port = remote_port;