Skip to content

Commit

Permalink
Hide "ghost rooms" from lobby listing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DyXel committed Apr 2, 2024
1 parent 355803b commit 506aa2b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Multirole/Endpoint/LobbyListing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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++)
{
Expand Down

0 comments on commit 506aa2b

Please sign in to comment.