feat(client_world): implement server exit acknowledgment with timeout

This commit is contained in:
2026-06-28 15:04:21 +08:00
parent d2636189a4
commit 429520b1f7
4 changed files with 31 additions and 6 deletions

View File

@@ -664,11 +664,13 @@ void ServerWorld::handle_player_login(const std::string& name,
}
void ServerWorld::handle_player_exit(const std::string& uuid) {
std::shared_ptr<Session> exit_session;
{
std::lock_guard lock(m_player_mutex);
auto it = m_players.find(uuid);
if (it != m_players.end()) {
Logger::info("Player {} Exit the Server", it->second.get_name());
exit_session = it->second.get_session();
m_players.erase(it);
} else {
Logger::error("Player {} isn't in Server", uuid);
@@ -678,6 +680,11 @@ void ServerWorld::handle_player_exit(const std::string& uuid) {
m_uuid_to_name.erase(uuid);
Arena arena;
auto* rsp = Arena::Create<LogoutRsp>(&arena);
rsp->set_uuid(uuid);
exit_session->send(make_packet(*rsp));
std::vector<std::shared_ptr<Session>> sessions;
{
std::shared_lock lock(m_player_mutex);
@@ -687,9 +694,6 @@ void ServerWorld::handle_player_exit(const std::string& uuid) {
}
for (auto& s : sessions) {
Arena arena;
auto* rsp = Arena::Create<LogoutRsp>(&arena);
rsp->set_uuid(uuid);
s->send(make_packet(*rsp));
}
}