Aktualizace na verzi 2.6.1
This commit is contained in:
parent
37a23ac99e
commit
99ed8af3ff
@ -15,6 +15,7 @@ This fork is based on https://github.com/yubox-node-org/ESPAsyncWebServer and in
|
|||||||
- Deployed in PlatformIO registry and Arduino IDE library manager
|
- Deployed in PlatformIO registry and Arduino IDE library manager
|
||||||
- CI
|
- CI
|
||||||
- Only supports ESP32
|
- Only supports ESP32
|
||||||
|
- Resurrected `AsyncWebSocketMessageBuffer` and `makeBuffer()` in order to make the fork API-compatible with the original library from me-no-dev regarding WebSocket.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
@ -23,13 +24,29 @@ Please look at the original libraries for more examples and documentation.
|
|||||||
|
|
||||||
[https://github.com/yubox-node-org/ESPAsyncWebServer](https://github.com/yubox-node-org/ESPAsyncWebServer)
|
[https://github.com/yubox-node-org/ESPAsyncWebServer](https://github.com/yubox-node-org/ESPAsyncWebServer)
|
||||||
|
|
||||||
## Pitfalls
|
## `AsyncWebSocketMessageBuffer` and `makeBuffer()`
|
||||||
|
|
||||||
The fork from yubox introduces some breaking API changes compared to the original library, especially regarding the use of `std::shared_ptr<std::vector<uint8_t>>` for WebSocket.
|
The fork from `yubox-node-org` introduces some breaking API changes compared to the original library, especially regarding the use of `std::shared_ptr<std::vector<uint8_t>>` for WebSocket.
|
||||||
Thanks to this fork, you can handle them by using `ASYNCWEBSERVER_FORK_mathieucarbou`.
|
|
||||||
|
|
||||||
Here is an example for serializing a Json document in a websocket message buffer directly.
|
This fork is compatible with the original library from `me-no-dev` regarding WebSocket, and wraps the optimizations done by `yubox-node-org` in the `AsyncWebSocketMessageBuffer` class.
|
||||||
This code is compatible with both forks.
|
So you have the choice of which API to use.
|
||||||
|
I strongly suggest to use the optimized API from `yubox-node-org` as it is much more efficient.
|
||||||
|
|
||||||
|
Here is an example for serializing a Json document in a websocket message buffer. This code is compatible with any forks, but not optimized:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
void send(JsonDocument& doc) {
|
||||||
|
const size_t len = measureJson(doc);
|
||||||
|
|
||||||
|
// original API from me-no-dev
|
||||||
|
AsyncWebSocketMessageBuffer* buffer = _ws->makeBuffer(len);
|
||||||
|
assert(buffer); // up to you to keep or remove this
|
||||||
|
serializeJson(doc, buffer->get(), len);
|
||||||
|
_ws->textAll(buffer);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is an example for serializing a Json document in a more optimized way, and compatible with both forks:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
void send(JsonDocument& doc) {
|
void send(JsonDocument& doc) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ESP Async WebServer",
|
"name": "ESP Async WebServer",
|
||||||
"version": "2.5.1",
|
"version": "2.6.1",
|
||||||
"description": "Asynchronous HTTP and WebSocket Server Library for ESP32. Supports: WebSocket, SSE, Authentication, Arduino Json 7, File Upload, Static File serving, URL Rewrite, URL Redirect, etc.",
|
"description": "Asynchronous HTTP and WebSocket Server Library for ESP32. Supports: WebSocket, SSE, Authentication, Arduino Json 7, File Upload, Static File serving, URL Rewrite, URL Redirect, etc.",
|
||||||
"keywords": "http,async,websocket,webserver",
|
"keywords": "http,async,websocket,webserver",
|
||||||
"homepage": "https://github.com/mathieucarbou/ESPAsyncWebServer",
|
"homepage": "https://github.com/mathieucarbou/ESPAsyncWebServer",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=ESP Async WebServer
|
name=ESP Async WebServer
|
||||||
version=2.5.1
|
version=2.6.1
|
||||||
author=Me-No-Dev
|
author=Me-No-Dev
|
||||||
maintainer=Mathieu Carbou <mathieu.carbou@gmail.com>
|
maintainer=Mathieu Carbou <mathieu.carbou@gmail.com>
|
||||||
sentence=Asynchronous HTTP and WebSocket Server Library for ESP32
|
sentence=Asynchronous HTTP and WebSocket Server Library for ESP32
|
||||||
|
@ -798,7 +798,7 @@ void AsyncWebSocketClient::binary(const __FlashStringHelper *data, size_t len)
|
|||||||
IPAddress AsyncWebSocketClient::remoteIP() const
|
IPAddress AsyncWebSocketClient::remoteIP() const
|
||||||
{
|
{
|
||||||
if (!_client)
|
if (!_client)
|
||||||
return IPAddress((uint32_t)0);
|
return IPAddress((uint32_t)0U);
|
||||||
|
|
||||||
return _client->remoteIP();
|
return _client->remoteIP();
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,9 @@
|
|||||||
#error Platform not supported
|
#error Platform not supported
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ASYNCWEBSERVER_VERSION "2.5.1"
|
#define ASYNCWEBSERVER_VERSION "2.6.1"
|
||||||
#define ASYNCWEBSERVER_VERSION_MAJOR 2
|
#define ASYNCWEBSERVER_VERSION_MAJOR 2
|
||||||
#define ASYNCWEBSERVER_VERSION_MINOR 5
|
#define ASYNCWEBSERVER_VERSION_MINOR 6
|
||||||
#define ASYNCWEBSERVER_VERSION_REVISION 1
|
#define ASYNCWEBSERVER_VERSION_REVISION 1
|
||||||
#define ASYNCWEBSERVER_FORK_mathieucarbou
|
#define ASYNCWEBSERVER_FORK_mathieucarbou
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ AsyncStaticWebHandler& AsyncStaticWebHandler::setCacheControl(const char* cache_
|
|||||||
}
|
}
|
||||||
|
|
||||||
AsyncStaticWebHandler& AsyncStaticWebHandler::setLastModified(const char* last_modified){
|
AsyncStaticWebHandler& AsyncStaticWebHandler::setLastModified(const char* last_modified){
|
||||||
_last_modified = String(last_modified);
|
_last_modified = last_modified;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +205,9 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request)
|
|||||||
return request->requestAuthentication();
|
return request->requestAuthentication();
|
||||||
|
|
||||||
if (request->_tempFile == true) {
|
if (request->_tempFile == true) {
|
||||||
String etag = String(request->_tempFile.size());
|
time_t lw = request->_tempFile.getLastWrite(); // get last file mod time (if supported by FS)
|
||||||
|
if (lw) setLastModified(gmtime(&lw));
|
||||||
|
String etag(lw ? lw : request->_tempFile.size()); // set etag to lastmod timestamp if available, otherwise to size
|
||||||
if (_last_modified.length() && _last_modified == request->header(F("If-Modified-Since"))) {
|
if (_last_modified.length() && _last_modified == request->header(F("If-Modified-Since"))) {
|
||||||
request->_tempFile.close();
|
request->_tempFile.close();
|
||||||
request->send(304); // Not modified
|
request->send(304); // Not modified
|
||||||
|
Loading…
Reference in New Issue
Block a user