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