From 506aa2bb49f830957a8acebb696da5fef72ce40e Mon Sep 17 00:00:00 2001 From: Dylam De La Torre Date: Tue, 2 Apr 2024 11:14:41 +0200 Subject: [PATCH] Hide "ghost rooms" from lobby listing This is NOT a proper fix to the problem, it's more like hiding the symptom. The real problem is really related to the design of the server and the protocol, both of which are not going to be changed anytime soon... So might as well not bother users with this. In a nutshell, somehow it is possible to have rooms that have apparently no users on them; When a client tries to join, it hangs as it expects more messages from the server, but they never arrive. As far as we know, the reason for these to exist is that ungraceful TCP disconnections are not handled properly, and TCP keepalives are not reliable enough to detect this. --- src/Multirole/Endpoint/LobbyListing.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Multirole/Endpoint/LobbyListing.cpp b/src/Multirole/Endpoint/LobbyListing.cpp index a79f332..adf8a4b 100644 --- a/src/Multirole/Endpoint/LobbyListing.cpp +++ b/src/Multirole/Endpoint/LobbyListing.cpp @@ -97,6 +97,9 @@ void LobbyListing::DoSerialize() auto& ar = *j.emplace("rooms", boost::json::array(&mr)).first->value().if_array(); lobby.CollectRooms([&](const Lobby::RoomProps& rp) { + const auto dCount = rp.duelists.usedCount; + if(dCount == 0) // NOTE: Hide "ghost rooms". + return; const auto& hi = *rp.hostInfo; auto& room = *ar.emplace_back(boost::json::object(21U, &mr)).if_object(); room.emplace("roomid", rp.id); @@ -125,7 +128,6 @@ void LobbyListing::DoSerialize() room.emplace("extra_max", hi.limits.extra.max); room.emplace("side_min", hi.limits.side.min); room.emplace("side_max", hi.limits.side.max); - const auto dCount = rp.duelists.usedCount; auto& ac = *room.emplace("users", boost::json::array(dCount, &mr)).first->value().if_array(); for(std::size_t i = 0; i < dCount; i++) {