#pragma once

#include "protocol/PacketHandler.h"
#include "network/TCPSocket.h"
#include "game/Connexion.h"

namespace td {
namespace client {

class ClientConnexion : public protocol::Connexion {
private:
    std::uint8_t m_ConnectionID;
    std::string m_DisconnectReason;
    float m_ServerTPS;
    int m_Ping = 0;
public:
    ClientConnexion();

    virtual bool updateSocket();

    virtual void HandlePacket(const protocol::KeepAlivePacket* packet);
    virtual void HandlePacket(const protocol::ConnexionInfoPacket* packet);
    virtual void HandlePacket(const protocol::DisconnectPacket* packet);
    virtual void HandlePacket(const protocol::ServerTpsPacket* packet);

    const std::string& getDisconnectReason() const { return m_DisconnectReason; }
    float getServerTPS() const { return m_ServerTPS; }
    int getServerPing() const { return m_Ping; }

    REMOVE_COPY(ClientConnexion);
private:
    void registerHandlers();
    void login();
};

} // namespace client
} // namespace td