From 8cd683229772b89fad31e6532c0c00fb87926501 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 4 Feb 2024 21:23:21 +0200 Subject: [PATCH] Handle errors from global lobby on client --- client/globalLobby/GlobalLobbyClient.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/client/globalLobby/GlobalLobbyClient.cpp b/client/globalLobby/GlobalLobbyClient.cpp index 687e77392..52acaee5d 100644 --- a/client/globalLobby/GlobalLobbyClient.cpp +++ b/client/globalLobby/GlobalLobbyClient.cpp @@ -66,7 +66,7 @@ void GlobalLobbyClient::onPacketReceived(const std::shared_ptrerror("Received unexpected message from lobby server: %s", json["type"].String()); } void GlobalLobbyClient::receiveAccountCreated(const JsonNode & json) @@ -94,10 +94,10 @@ void GlobalLobbyClient::receiveOperationFailed(const JsonNode & json) { auto loginWindowPtr = loginWindow.lock(); - if(!loginWindowPtr || !GH.windows().topWindow()) - throw std::runtime_error("lobby connection finished without active login window!"); + if(loginWindowPtr) + loginWindowPtr->onConnectionFailed(json["reason"].String()); - loginWindowPtr->onConnectionFailed(json["reason"].String()); + // TODO: handle errors in lobby menu } void GlobalLobbyClient::receiveLoginSuccess(const JsonNode & json) @@ -257,7 +257,12 @@ void GlobalLobbyClient::onDisconnected(const std::shared_ptr assert(connection == networkConnection); networkConnection.reset(); - GH.windows().popWindows(1); + while (!GH.windows().findWindows().empty()) + { + // if global lobby is open, pop all dialogs on top of it as well as lobby itself + GH.windows().popWindows(1); + } + CInfoWindow::showInfoDialog("Connection to game lobby was lost!", {}); }