Updated TCPServer and WEBServer core logic
This commit is contained in:
parent
1450a8c0e5
commit
c777e23a52
@ -140,9 +140,9 @@ class TCPServer
|
||||
|
||||
if(_currentClient->_dataSize > 0)
|
||||
{
|
||||
processClientData(_currentClient);//We process the actual data
|
||||
_currentClient->_newDataAvailable = false;
|
||||
}
|
||||
processClientData(_currentClient);//We process the actual data
|
||||
|
||||
if(_currentClient->_clientState == TCPClient::ClientState::DISCARDED)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ class WEBServer : public TCPServer<T>
|
||||
uint16_t maxBodyBuffer;
|
||||
};
|
||||
|
||||
WEBServer(unsigned int port = 80, SDCardManager *sdCardManager = NULL, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 512) : TCPServer<T>(port, maxClient, clientDataBufferSize), _sdCardManager(sdCardManager) {}
|
||||
WEBServer(unsigned int port = 80, SDCardManager *sdCardManager = NULL, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 255) : TCPServer<T>(port, maxClient, clientDataBufferSize), _sdCardManager(sdCardManager) {}
|
||||
|
||||
boolean addApiRoutine(const char *uri, boolean (*apiRoutine)(HttpRequestData&, WiFiClient*, void*), void *pData, HttpRequestMethod HRM = UNDEFINED)
|
||||
{
|
||||
@ -51,7 +51,7 @@ class WEBServer : public TCPServer<T>
|
||||
private:
|
||||
virtual T* createNewClient(WiFiClient wc)
|
||||
{
|
||||
return new T(wc, TCPServer<T>::freeClientId());
|
||||
return new T(wc, TCPServer<T>::freeClientId(), TCPServer<T>::_clientDataBufferSize);
|
||||
}
|
||||
|
||||
virtual void greetClient(T *client)
|
||||
@ -61,33 +61,36 @@ class WEBServer : public TCPServer<T>
|
||||
|
||||
virtual void processClientData(T *client)
|
||||
{
|
||||
switch(client->_WEBClientState)
|
||||
if(client->_dataSize > 0)
|
||||
{
|
||||
case ACCEPTED:
|
||||
#ifdef DEBUG_WEBS
|
||||
Serial.println("WEBServer : ACCEPTED");
|
||||
#endif
|
||||
queryParser(client);
|
||||
break;
|
||||
case QUERY_PARSED:
|
||||
#ifdef DEBUG_WEBS
|
||||
Serial.println("WEBServer : QUERY_PARSED");
|
||||
#endif
|
||||
sendDataToClient(client);
|
||||
break;
|
||||
case RESPONSE_SENT:
|
||||
#ifdef DEBUG_WEBS
|
||||
Serial.println("WEBServer : RESPONSE_SENT");
|
||||
#endif
|
||||
client->_WEBClientState = WEBClientState::DONE;
|
||||
break;
|
||||
case DONE:
|
||||
#ifdef DEBUG_WEBS
|
||||
Serial.println("WEBServer : DONE");
|
||||
#endif
|
||||
client->_clientState = TCPClient::ClientState::DISCARDED;
|
||||
break;
|
||||
}
|
||||
switch(client->_WEBClientState)
|
||||
{
|
||||
case ACCEPTED:
|
||||
#ifdef DEBUG_WEBS
|
||||
Serial.println("WEBServer : ACCEPTED");
|
||||
#endif
|
||||
queryParser(client);
|
||||
break;
|
||||
case QUERY_PARSED:
|
||||
#ifdef DEBUG_WEBS
|
||||
Serial.println("WEBServer : QUERY_PARSED");
|
||||
#endif
|
||||
sendDataToClient(client);
|
||||
break;
|
||||
case RESPONSE_SENT:
|
||||
#ifdef DEBUG_WEBS
|
||||
Serial.println("WEBServer : RESPONSE_SENT");
|
||||
#endif
|
||||
client->_WEBClientState = WEBClientState::DONE;
|
||||
break;
|
||||
case DONE:
|
||||
#ifdef DEBUG_WEBS
|
||||
Serial.println("WEBServer : DONE");
|
||||
#endif
|
||||
client->_clientState = TCPClient::ClientState::DISCARDED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void queryParser(T *client)
|
||||
|
@ -17,5 +17,6 @@
|
||||
#define SOFT_VERSION "1.2.1" //Corrected a bug in the TaskSchedulerManager class
|
||||
#define SOFT_VERSION "1.3.0" //Implemented multi-client non blocking webserver
|
||||
#define SOFT_VERSION "1.3.1" //Fixed sdCardUnmount api call
|
||||
#define SOFT_VERSION "1.3.2" //Modified TCPServer and WEBServer core logic
|
||||
|
||||
#endif //VERSIONS_H
|
||||
|
Loading…
Reference in New Issue
Block a user