#pragma once

#include "blitz/misc/ObjectNotifier.h"
#include "blitz/protocol/packets/ChatPacket.h"
#include <cstdint>
#include <memory>
#include <string>

namespace blitz {

namespace client {
class ClientConnexion;
}  // namespace client

namespace server {
class Server;
}  // namespace server

class ChatListener {
  public:
	virtual void OnTextChatReceived(const protocol::ColoredText& text) {}
};

// Singleton
class Client : public utils::ObjectNotifier<ChatListener> {
  private:
	std::unique_ptr<server::Server> m_Server;
	std::unique_ptr<client::ClientConnexion> m_Connexion;

  public:
	Client();
	virtual ~Client();

	void Update();

	bool IsConnected();

	bool JoinGame(const std::string& pseudo, const std::string& address, std::uint16_t port);
	bool CreateGame(std::uint16_t port, const std::string& pseudo);

	void SendChatText(const std::string& text);
	void ChatTextReceived(const protocol::ColoredText& text);
};

}  // namespace blitz
