Added method to access clients of AsyncWebSocket (#583)

* Added method to access clients of AsyncWebSocket

* https://github.com/me-no-dev/ESPAsyncWebServer/issues/571

* Conflict with crypto library
This commit is contained in:
sascha lammers 2019-10-02 04:16:43 -07:00 committed by Me No Dev
parent 8451c0d0e7
commit 403752a942
3 changed files with 12 additions and 1 deletions

View File

@ -1236,6 +1236,9 @@ void AsyncWebSocket::_cleanBuffers()
}
}
AsyncWebSocket::AsyncWebSocketClientLinkedList AsyncWebSocket::getClients() const {
return _clients;
}
/*
* Response to Web Socket request - sends the authorization and detaches the TCP Client from the web server

View File

@ -35,6 +35,9 @@
#ifdef ESP8266
#include <Hash.h>
#ifdef CRYPTO_HASH_h // include Hash.h from espressif framework if the first include was from the crypto library
#include <../src/Hash.h>
#endif
#endif
#ifdef ESP32
@ -238,9 +241,11 @@ typedef std::function<void(AsyncWebSocket * server, AsyncWebSocketClient * clien
//WebServer Handler implementation that plays the role of a socket server
class AsyncWebSocket: public AsyncWebHandler {
public:
typedef LinkedList<AsyncWebSocketClient *> AsyncWebSocketClientLinkedList;
private:
String _url;
LinkedList<AsyncWebSocketClient *> _clients;
AsyncWebSocketClientLinkedList _clients;
uint32_t _cNextId;
AwsEventHandler _eventHandler;
bool _enabled;
@ -325,6 +330,8 @@ class AsyncWebSocket: public AsyncWebHandler {
AsyncWebSocketMessageBuffer * makeBuffer(uint8_t * data, size_t size);
LinkedList<AsyncWebSocketMessageBuffer *> _buffers;
void _cleanBuffers();
AsyncWebSocketClientLinkedList getClients() const;
};
//WebServer response to authenticate the socket and detach the tcp client from the web server request

View File

@ -446,6 +446,7 @@ size_t AsyncAbstractResponse::_fillBufferAndProcessTemplates(uint8_t* data, size
_cache.insert(_cache.begin(), &data[originalLen - (pTemplateStart + numBytesCopied - pTemplateEnd - 1)], &data[len]);
//2. parameter value is longer than placeholder text, push the data after placeholder which not saved into cache further to the end
memmove(pTemplateStart + numBytesCopied, pTemplateEnd + 1, &data[originalLen] - pTemplateStart - numBytesCopied);
len = originalLen; // fix issue with truncated data, not sure if it has any side effects
} else if(pTemplateEnd + 1 != pTemplateStart + numBytesCopied)
//2. Either parameter value is shorter than placeholder text OR there is enough free space in buffer to fit.
// Move the entire data after the placeholder