添加断线重连处理
This commit is contained in:
parent
053cfb95ae
commit
12f218650a
@ -13,6 +13,6 @@ enum SSMessageId_e
|
|||||||
_SS_CMPing = 101;
|
_SS_CMPing = 101;
|
||||||
_SS_SMRpcError = 102;
|
_SS_SMRpcError = 102;
|
||||||
_SS_CMLogin = 103;
|
_SS_CMLogin = 103;
|
||||||
_SS_CMReConnect = 104;
|
_SS_CMReconnect = 104;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,14 @@ message SS_CMLogin_CMReConnect_CommonHead
|
|||||||
optional int32 server_id = 1;
|
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 int32 server_id = 1; //保留
|
||||||
optional string team_uuid = 2; //保留
|
optional string team_uuid = 2; //保留
|
||||||
@ -28,6 +35,8 @@ message SS_WSP_RequestTargetServer
|
|||||||
optional int64 context_id = 1;
|
optional int64 context_id = 1;
|
||||||
optional string account_id = 2;
|
optional string account_id = 2;
|
||||||
optional string team_id = 3;
|
optional string team_id = 3;
|
||||||
|
optional string server_info = 4;
|
||||||
|
optional int32 is_reconnect = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SS_MS_ResponseTargetServer
|
message SS_MS_ResponseTargetServer
|
||||||
|
@ -422,11 +422,42 @@ void App::ProcessClientMsg(f8::MsgHdr& hdr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if MASTER_MODE
|
#if MASTER_MODE
|
||||||
if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReConnect) {
|
if (hdr.msgid == ss::_SS_CMLogin || hdr.msgid == ss::_SS_CMReconnect) {
|
||||||
ss::SS_CMLogin_CMReConnect_CommonHead2 msg;
|
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);
|
bool ok = msg.ParseFromArray(hdr.buf + hdr.offset, hdr.buflen - hdr.offset);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
MasterSvrMgr::Instance()->RequestTargetServer(hdr, msg.team_uuid(), msg.account_id());
|
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 {
|
} else {
|
||||||
GameClient* client = GameClientMgr::Instance()->GetGameClientBySocket(hdr.socket_handle);
|
GameClient* client = GameClientMgr::Instance()->GetGameClientBySocket(hdr.socket_handle);
|
||||||
@ -487,7 +518,7 @@ void App::ProcessTargetServerMsg(f8::MsgHdr& hdr)
|
|||||||
if (hdr.msgid < 100) {
|
if (hdr.msgid < 100) {
|
||||||
return;
|
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);
|
GameClientMgr::Instance()->BindTargetConn(hdr.socket_handle, hdr.ip_saddr);
|
||||||
GCListener::Instance()->MarkClient(hdr.socket_handle, true);
|
GCListener::Instance()->MarkClient(hdr.socket_handle, true);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,11 @@ 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, 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
|
#if GAME_ID == 9003
|
||||||
{
|
{
|
||||||
@ -113,6 +117,8 @@ void MasterSvrMgr::RequestTargetServer(f8::MsgHdr& hdr, const std::string& team_
|
|||||||
ss::SS_WSP_RequestTargetServer msg;
|
ss::SS_WSP_RequestTargetServer msg;
|
||||||
msg.set_context_id(curr_context_id_);
|
msg.set_context_id(curr_context_id_);
|
||||||
msg.set_team_id(team_uuid);
|
msg.set_team_id(team_uuid);
|
||||||
|
msg.set_server_info(server_info);
|
||||||
|
msg.set_is_reconnect(is_reconnect);
|
||||||
svr->SendMsg(msg);
|
svr->SendMsg(msg);
|
||||||
|
|
||||||
pending_socket_hash_[hdr.socket_handle] = curr_context_id_;
|
pending_socket_hash_[hdr.socket_handle] = curr_context_id_;
|
||||||
|
@ -26,7 +26,11 @@ 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, 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);
|
void RemoveRequest(int socket_handle, long long context_id, bool auto_free);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user