35 lines
		
	
	
		
			893 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			893 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #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);
 | |
|     void closeConnection();
 | |
|   protected:
 | |
|     enum ClientState {NEW, HANDLED, DISCARDED} _clientState = NEW;
 | |
|     enum Error {OK = 0, MALLOC_ERR = 1} _error = OK;
 | |
|   
 | |
|     WiFiClient _client;
 | |
|     uint8_t *_data = NULL; //The actual data
 | |
|     uint16_t _dataSize = 0; //The logical size of the data contained
 | |
|     uint16_t _dataBufferSize; //The physical size of the buffer
 | |
|     boolean _newDataAvailable = false;
 | |
|     uint8_t _id;
 | |
| 
 | |
|     void freeDataBuffer(uint16_t size);
 | |
|   private:
 | |
| };
 | |
| 
 | |
| #endif //TCPCLIENT_H
 |