#pragma once

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

namespace td {
namespace client {

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

	virtual bool UpdateSocket();

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

	const std::string& GetDisconnectReason() const { return m_DisconnectReason; }
	float GetServerTPS() const { return m_ServerTPS; }
	float GetServerMSPT() const { return m_ServerMSPT; }
	int GetServerPing() const { return m_Ping; }

	REMOVE_COPY(ClientConnexion);
private:
	void RegisterHandlers();
	void Login();
};

} // namespace client
} // namespace td