完成断线重连逻辑

This commit is contained in:
aozhiwei 2020-08-10 16:12:11 +08:00
parent ac9ca132c0
commit 5c093d1505
4 changed files with 9 additions and 1 deletions

View File

@ -921,6 +921,7 @@ void Player::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
respmsg.set_errcode(0);
respmsg.set_errmsg("战斗重连成功");
SendNotifyMsg(respmsg);
PlayerMgr::Instance()->ReBindSocket(this);
}
void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)

View File

@ -194,3 +194,9 @@ void PlayerMgr::DecAccountNum(const std::string& account_id)
);
}
}
void PlayerMgr::ReBindSocket(Player* hum)
{
socket_hash_[hum->socket_handle] = hum;
IncAccountNum(hum->account_id);
}

View File

@ -36,6 +36,7 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
size_t GetAccountNum() { return account_num_hash_.size(); }
void IncAccountNum(const std::string& account_id);
void DecAccountNum(const std::string& account_id);
void ReBindSocket(Player* hum);
private:
std::map<int, Player*> socket_hash_;

View File

@ -190,7 +190,7 @@ void RoomMgr::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
send_reconnect_failed(hdr.socket_handle, 1, "房间已销毁");
return;
}
if (room->GetRoomMode() == kChiJiMode) {
if (room->GetRoomMode() != kChiJiMode) {
send_reconnect_failed(hdr.socket_handle, 1, "只有吃鸡模式支持重连");
return;
}