1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-02 09:02:03 +02:00
vcmi/client/globalLobby/GlobalLobbyClient.h

69 lines
2.2 KiB
C++
Raw Normal View History

/*
* GlobalLobbyClient.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "GlobalLobbyDefines.h"
2024-01-12 01:10:41 +02:00
#include "../../lib/network/NetworkInterface.h"
VCMI_LIB_NAMESPACE_BEGIN
class JsonNode;
VCMI_LIB_NAMESPACE_END
class GlobalLobbyLoginWindow;
class GlobalLobbyWindow;
class GlobalLobbyClient final : public INetworkClientListener, boost::noncopyable
{
std::vector<GlobalLobbyAccount> activeAccounts;
std::vector<GlobalLobbyRoom> activeRooms;
2024-01-12 16:55:36 +02:00
std::shared_ptr<INetworkConnection> networkConnection;
std::weak_ptr<GlobalLobbyLoginWindow> loginWindow;
std::weak_ptr<GlobalLobbyWindow> lobbyWindow;
std::shared_ptr<GlobalLobbyWindow> lobbyWindowLock; // helper strong reference to prevent window destruction on closing
2024-01-12 01:10:41 +02:00
void onPacketReceived(const std::shared_ptr<INetworkConnection> &, const std::vector<uint8_t> & message) override;
2023-11-12 13:27:22 +02:00
void onConnectionFailed(const std::string & errorMessage) override;
2024-01-12 01:10:41 +02:00
void onConnectionEstablished(const std::shared_ptr<INetworkConnection> &) override;
void onDisconnected(const std::shared_ptr<INetworkConnection> &) override;
void sendClientRegister();
void sendClientLogin();
void receiveAccountCreated(const JsonNode & json);
void receiveLoginFailed(const JsonNode & json);
void receiveLoginSuccess(const JsonNode & json);
void receiveChatHistory(const JsonNode & json);
void receiveChatMessage(const JsonNode & json);
void receiveActiveAccounts(const JsonNode & json);
void receiveActiveGameRooms(const JsonNode & json);
void receiveJoinRoomSuccess(const JsonNode & json);
std::shared_ptr<GlobalLobbyLoginWindow> createLoginWindow();
std::shared_ptr<GlobalLobbyWindow> createLobbyWindow();
2024-01-11 22:51:36 +02:00
public:
2024-01-12 16:55:36 +02:00
explicit GlobalLobbyClient();
~GlobalLobbyClient();
const std::vector<GlobalLobbyAccount> & getActiveAccounts() const;
const std::vector<GlobalLobbyRoom> & getActiveRooms() const;
/// Activate interface and pushes lobby UI as top window
void activateInterface();
void sendMessage(const JsonNode & data);
void sendOpenPublicRoom();
void sendOpenPrivateRoom();
void connect();
bool isConnected();
};