1
This commit is contained in:
parent
275709d03a
commit
a6c8f4c85d
@ -17,6 +17,7 @@ message SS_CMLogin_CMReConnect_CommonHead2
|
||||
{
|
||||
optional int32 server_id = 1;
|
||||
optional string team_uuid = 2;
|
||||
optional string account_id = 3;
|
||||
}
|
||||
|
||||
message SS_WSP_RequestTargetServer
|
||||
|
@ -382,7 +382,7 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr)
|
||||
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());
|
||||
MasterSvrMgr::Instance()->RequestTargetServer(hdr, msg.team_uuid(), msg.account_id());
|
||||
}
|
||||
} else {
|
||||
GameClient* client = GameClientMgr::Instance()->GetGameClientBySocket(hdr.socket_handle);
|
||||
@ -626,4 +626,3 @@ void App::FreeIMMsgQueue()
|
||||
}
|
||||
im_msg_mutex_->unlock();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <a8/openssl.h>
|
||||
#include <a8/timer.h>
|
||||
|
||||
@ -64,17 +66,19 @@ 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)
|
||||
void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_id, const std::string& account_id)
|
||||
{
|
||||
if (GetContextIdBySocket(hdr.socket_handle) != 0) {
|
||||
return;
|
||||
}
|
||||
unsigned int code = a8::openssl::Crc32((unsigned char*)team_id.data(), team_id.size());
|
||||
#if 1
|
||||
MasterSvr* svr = GetConnById(2);
|
||||
#else
|
||||
unsigned int code = 0;
|
||||
if (!team_id.empty()) {
|
||||
code = a8::openssl::Crc32((unsigned char*)team_id.data(), team_id.size());
|
||||
} 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);
|
||||
#endif
|
||||
if (svr) {
|
||||
++curr_context_id_;
|
||||
a8::TimerAttacher* timer_attacher = new a8::TimerAttacher();
|
||||
|
@ -26,7 +26,7 @@ class MasterSvrMgr : public a8::Singleton<MasterSvrMgr>
|
||||
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 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);
|
||||
|
||||
private:
|
||||
|
@ -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)
|
||||
{
|
||||
if (remote_ip.empty()) {
|
||||
abort();
|
||||
}
|
||||
this->instance_id = instance_id;
|
||||
this->remote_ip = remote_ip;
|
||||
this->remote_port = remote_port;
|
||||
|
Loading…
x
Reference in New Issue
Block a user