This commit is contained in:
2025-08-23 12:54:48 +02:00
parent 73dd2dabfa
commit 1d436aa1c3
12 changed files with 93 additions and 24 deletions

View File

@@ -3,27 +3,38 @@
#include <client/IClientSocket.h>
#include <client/PlayerManager.h>
#include <td/common/StateMachine.h>
#include <optional>
namespace td {
namespace client {
class ClientState;
class LoggingState;
class Client : public StateMachine<Client, void, float> {
private:
std::shared_ptr<IClientSocket> m_Socket;
PlayerManager m_Players;
std::optional<PlayerID> m_Id;
public:
Client(const std::shared_ptr<IClientSocket>& a_Socket, const std::string& a_PlayerName);
Client(const std::shared_ptr<IClientSocket>& a_Socket);
~Client();
void SendPacket(const protocol::PacketBase& a_Packet);
void Disconnect();
const PlayerManager& GetPlayers() const {
return m_Players;
}
const std::optional<PlayerID> GetId() const {
return m_Id;
}
friend class ClientState;
friend class LoggingState;
};
} // namespace client

View File

@@ -14,6 +14,7 @@ class IClientSocket {
utils::Signal<const protocol::PacketBase&> OnReceive;
virtual void Send(const protocol::PacketBase& a_Packet) = 0;
virtual void Disconnect() = 0;
IClientSocket() {}
virtual ~IClientSocket() {}

View File

@@ -27,6 +27,7 @@ class FakeSocket : public IClientSocket {
void ReceiveFromFakePeer(PeerID a_Peer, const protocol::PacketBase& a_Packet);
virtual void Send(const protocol::PacketBase& a_Packet) override;
virtual void Disconnect() override;
};
} // namespace client