#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <ESP8266WiFi.h>

//Forward class declaration
template <typename T> class TCPServer;

class TCPClient
{ 
  template<typename T>
  friend class TCPServer;
  public:
	  TCPClient(WiFiClient client, uint8_t id, uint16_t dataBufferSize = 255);
    TCPClient(const TCPClient &Object);
	  virtual ~TCPClient();
    bool operator==(TCPClient& Object);
    bool closeConnection();
  protected:
    enum ClientState {NEW, HANDLED, DISCARDED} _clientState;
    enum Error {OK = 0, MALLOC_ERR = 1} _error;
  
    WiFiClient _client;
    uint8_t *_data; //The actual data
    uint16_t _dataSize; //The logic size of the data contained
    uint16_t _dataBufferSize; //The physic size of the buffer
    boolean _newDataAvailable;
    uint8_t _id;

    void freeDataBuffer(uint16_t size);
  private:
};

#endif //TCPCLIENT_H
