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:
parent
8451c0d0e7
commit
403752a942
|
@ -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
|
* Response to Web Socket request - sends the authorization and detaches the TCP Client from the web server
|
||||||
|
|
|
@ -35,6 +35,9 @@
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#include <Hash.h>
|
#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
|
#endif
|
||||||
|
|
||||||
#ifdef ESP32
|
#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
|
//WebServer Handler implementation that plays the role of a socket server
|
||||||
class AsyncWebSocket: public AsyncWebHandler {
|
class AsyncWebSocket: public AsyncWebHandler {
|
||||||
|
public:
|
||||||
|
typedef LinkedList<AsyncWebSocketClient *> AsyncWebSocketClientLinkedList;
|
||||||
private:
|
private:
|
||||||
String _url;
|
String _url;
|
||||||
LinkedList<AsyncWebSocketClient *> _clients;
|
AsyncWebSocketClientLinkedList _clients;
|
||||||
uint32_t _cNextId;
|
uint32_t _cNextId;
|
||||||
AwsEventHandler _eventHandler;
|
AwsEventHandler _eventHandler;
|
||||||
bool _enabled;
|
bool _enabled;
|
||||||
|
@ -325,6 +330,8 @@ class AsyncWebSocket: public AsyncWebHandler {
|
||||||
AsyncWebSocketMessageBuffer * makeBuffer(uint8_t * data, size_t size);
|
AsyncWebSocketMessageBuffer * makeBuffer(uint8_t * data, size_t size);
|
||||||
LinkedList<AsyncWebSocketMessageBuffer *> _buffers;
|
LinkedList<AsyncWebSocketMessageBuffer *> _buffers;
|
||||||
void _cleanBuffers();
|
void _cleanBuffers();
|
||||||
|
|
||||||
|
AsyncWebSocketClientLinkedList getClients() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//WebServer response to authenticate the socket and detach the tcp client from the web server request
|
//WebServer response to authenticate the socket and detach the tcp client from the web server request
|
||||||
|
|
|
@ -446,6 +446,7 @@ size_t AsyncAbstractResponse::_fillBufferAndProcessTemplates(uint8_t* data, size
|
||||||
_cache.insert(_cache.begin(), &data[originalLen - (pTemplateStart + numBytesCopied - pTemplateEnd - 1)], &data[len]);
|
_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
|
//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);
|
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)
|
} 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.
|
//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
|
// Move the entire data after the placeholder
|
||||||
|
|
Loading…
Reference in New Issue