#pragma once

#include "TCPSocket.h"
#include "blitz/protocol/PacketDispatcher.h"
#include "blitz/protocol/PacketHandler.h"

namespace blitz {
namespace network {

class Connexion : public protocol::PacketHandler {
  protected:
	protocol::PacketDispatcher m_Dispatcher;

  private:
	TCPSocket m_Socket;

  public:
	Connexion(protocol::PacketDispatcher* dispatcher);
	Connexion(protocol::PacketDispatcher* dispatcher, TCPSocket& socket);
	Connexion(Connexion&& move);

	virtual ~Connexion();

	virtual bool UpdateSocket();
	void CloseConnection();

	virtual bool Connect(const std::string& address, std::uint16_t port);

	TCPSocket::Status GetSocketStatus() const {
		return m_Socket.GetStatus();
	}

	void SendPacket(const protocol::Packet* packet);

	REMOVE_COPY(Connexion);
};

}  // namespace network
}  // namespace blitz
