mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Handle errors from global lobby on client
This commit is contained in:
@@ -66,7 +66,7 @@ void GlobalLobbyClient::onPacketReceived(const std::shared_ptr<INetworkConnectio
|
|||||||
if(json["type"].String() == "joinRoomSuccess")
|
if(json["type"].String() == "joinRoomSuccess")
|
||||||
return receiveJoinRoomSuccess(json);
|
return receiveJoinRoomSuccess(json);
|
||||||
|
|
||||||
throw std::runtime_error("Received unexpected message from lobby server: " + json["type"].String());
|
logGlobal->error("Received unexpected message from lobby server: %s", json["type"].String());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalLobbyClient::receiveAccountCreated(const JsonNode & json)
|
void GlobalLobbyClient::receiveAccountCreated(const JsonNode & json)
|
||||||
@@ -94,10 +94,10 @@ void GlobalLobbyClient::receiveOperationFailed(const JsonNode & json)
|
|||||||
{
|
{
|
||||||
auto loginWindowPtr = loginWindow.lock();
|
auto loginWindowPtr = loginWindow.lock();
|
||||||
|
|
||||||
if(!loginWindowPtr || !GH.windows().topWindow<GlobalLobbyLoginWindow>())
|
if(loginWindowPtr)
|
||||||
throw std::runtime_error("lobby connection finished without active login window!");
|
loginWindowPtr->onConnectionFailed(json["reason"].String());
|
||||||
|
|
||||||
loginWindowPtr->onConnectionFailed(json["reason"].String());
|
// TODO: handle errors in lobby menu
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalLobbyClient::receiveLoginSuccess(const JsonNode & json)
|
void GlobalLobbyClient::receiveLoginSuccess(const JsonNode & json)
|
||||||
@@ -257,7 +257,12 @@ void GlobalLobbyClient::onDisconnected(const std::shared_ptr<INetworkConnection>
|
|||||||
assert(connection == networkConnection);
|
assert(connection == networkConnection);
|
||||||
networkConnection.reset();
|
networkConnection.reset();
|
||||||
|
|
||||||
GH.windows().popWindows(1);
|
while (!GH.windows().findWindows<GlobalLobbyWindow>().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!", {});
|
CInfoWindow::showInfoDialog("Connection to game lobby was lost!", {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user