mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Distinguish "connected but not logged in" from "not connected" state
Possible in case of login failure
This commit is contained in:
parent
699616c984
commit
dd91a99e36
@ -106,10 +106,9 @@ void GlobalLobbyClient::receiveOperationFailed(const JsonNode & json)
|
||||
|
||||
void GlobalLobbyClient::receiveClientLoginSuccess(const JsonNode & json)
|
||||
{
|
||||
{
|
||||
setAccountDisplayName(json["displayName"].String());
|
||||
setAccountCookie(json["accountCookie"].String());
|
||||
}
|
||||
accountLoggedIn = true;
|
||||
setAccountDisplayName(json["displayName"].String());
|
||||
setAccountCookie(json["accountCookie"].String());
|
||||
|
||||
auto loginWindowPtr = loginWindow.lock();
|
||||
|
||||
@ -343,6 +342,7 @@ void GlobalLobbyClient::onDisconnected(const std::shared_ptr<INetworkConnection>
|
||||
|
||||
assert(connection == networkConnection);
|
||||
networkConnection.reset();
|
||||
accountLoggedIn = false;
|
||||
|
||||
while (!GH.windows().findWindows<GlobalLobbyWindow>().empty())
|
||||
{
|
||||
@ -376,6 +376,11 @@ void GlobalLobbyClient::connect()
|
||||
CSH->getNetworkHandler().connectToRemote(*this, hostname, port);
|
||||
}
|
||||
|
||||
bool GlobalLobbyClient::isLoggedIn() const
|
||||
{
|
||||
return networkConnection != nullptr && accountLoggedIn;
|
||||
}
|
||||
|
||||
bool GlobalLobbyClient::isConnected() const
|
||||
{
|
||||
return networkConnection != nullptr;
|
||||
@ -461,7 +466,7 @@ void GlobalLobbyClient::activateInterface()
|
||||
if (!GH.windows().findWindows<GlobalLobbyLoginWindow>().empty())
|
||||
return;
|
||||
|
||||
if (isConnected())
|
||||
if (isLoggedIn())
|
||||
GH.windows().pushWindow(createLobbyWindow());
|
||||
else
|
||||
GH.windows().pushWindow(createLoginWindow());
|
||||
@ -534,7 +539,7 @@ void GlobalLobbyClient::resetMatchState()
|
||||
|
||||
void GlobalLobbyClient::sendMatchChatMessage(const std::string & messageText)
|
||||
{
|
||||
if (!isConnected())
|
||||
if (!isLoggedIn())
|
||||
return; // we are not playing with lobby
|
||||
|
||||
if (currentGameRoomUUID.empty())
|
||||
|
@ -34,6 +34,7 @@ class GlobalLobbyClient final : public INetworkClientListener, boost::noncopyabl
|
||||
|
||||
std::shared_ptr<INetworkConnection> networkConnection;
|
||||
std::string currentGameRoomUUID;
|
||||
bool accountLoggedIn = false;
|
||||
|
||||
std::weak_ptr<GlobalLobbyLoginWindow> loginWindow;
|
||||
std::weak_ptr<GlobalLobbyWindow> lobbyWindow;
|
||||
@ -93,5 +94,6 @@ public:
|
||||
|
||||
void connect();
|
||||
bool isConnected() const;
|
||||
bool isLoggedIn() const;
|
||||
bool isInvitedToRoom(const std::string & gameRoomID);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user