Fixed some errors related to disconnecting

This commit is contained in:
Yousef Khadadeh 2025-12-09 17:20:27 +03:00
parent 9649135f43
commit 65436429b8
7 changed files with 119 additions and 56 deletions

View file

@ -26,8 +26,20 @@ void NetServer::update() {
if(client->setToDisconnect)
disconnectCallback(client);
else {
client->parse_received_messages(*this);
client->send_queued_messages(*this);
try {
client->parse_received_messages(*this);
client->send_queued_messages(*this);
}
catch(const std::exception& e) {
Logger::get().log("INFO", "[NetServer::update] Exception thrown while parsing and sending messages for a client: " + std::string(e.what()));
client->setToDisconnect = true;
disconnectCallback(client);
}
catch(...) {
Logger::get().log("INFO", "[NetServer::update] Unknown exception thrown while parsing and sending messages for a client.");
client->setToDisconnect = true;
disconnectCallback(client);
}
}
}
}