mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
feat(client_world): implement server exit acknowledgment with timeout
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user