mirror of
https://github.com/me-no-dev/ESPAsyncWebServer.git
synced 2025-08-02 20:24:40 +02:00
Merge branch 'main' into ssl_fastrst
This commit is contained in:
@@ -147,6 +147,8 @@ AsyncMiddlewareFunction complexAuth([](AsyncWebServerRequest* request, ArMiddlew
|
|||||||
|
|
||||||
AuthorizationMiddleware authz([](AsyncWebServerRequest* request) { return request->getAttribute("role") == "staff"; });
|
AuthorizationMiddleware authz([](AsyncWebServerRequest* request) { return request->getAttribute("role") == "staff"; });
|
||||||
|
|
||||||
|
int wsClients = 0;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
const char* PARAM_MESSAGE PROGMEM = "message";
|
const char* PARAM_MESSAGE PROGMEM = "message";
|
||||||
@@ -646,10 +648,14 @@ void setup() {
|
|||||||
ws.onEvent([](AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len) {
|
ws.onEvent([](AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len) {
|
||||||
(void)len;
|
(void)len;
|
||||||
if (type == WS_EVT_CONNECT) {
|
if (type == WS_EVT_CONNECT) {
|
||||||
|
wsClients++;
|
||||||
|
ws.textAll("new client connected");
|
||||||
Serial.println("ws connect");
|
Serial.println("ws connect");
|
||||||
client->setCloseClientOnQueueFull(false);
|
client->setCloseClientOnQueueFull(false);
|
||||||
client->ping();
|
client->ping();
|
||||||
} else if (type == WS_EVT_DISCONNECT) {
|
} else if (type == WS_EVT_DISCONNECT) {
|
||||||
|
wsClients--;
|
||||||
|
ws.textAll("client disconnected");
|
||||||
Serial.println("ws disconnect");
|
Serial.println("ws disconnect");
|
||||||
} else if (type == WS_EVT_ERROR) {
|
} else if (type == WS_EVT_ERROR) {
|
||||||
Serial.println("ws error");
|
Serial.println("ws error");
|
||||||
@@ -760,6 +766,8 @@ uint32_t deltaSSE = 10;
|
|||||||
uint32_t lastWS = 0;
|
uint32_t lastWS = 0;
|
||||||
uint32_t deltaWS = 100;
|
uint32_t deltaWS = 100;
|
||||||
|
|
||||||
|
uint32_t lastHeap = 0;
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
if (now - lastSSE >= deltaSSE) {
|
if (now - lastSSE >= deltaSSE) {
|
||||||
@@ -773,4 +781,8 @@ void loop() {
|
|||||||
// }
|
// }
|
||||||
lastWS = millis();
|
lastWS = millis();
|
||||||
}
|
}
|
||||||
|
if(now - lastHeap >= 2000) {
|
||||||
|
Serial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
|
||||||
|
lastHeap = now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ build_flags =
|
|||||||
-Og
|
-Og
|
||||||
-Wall -Wextra
|
-Wall -Wextra
|
||||||
-Wno-unused-parameter
|
-Wno-unused-parameter
|
||||||
-D CONFIG_ARDUHAL_LOG_COLORS
|
; -D CONFIG_ARDUHAL_LOG_COLORS
|
||||||
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
|
||||||
-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000
|
-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000
|
||||||
-D CONFIG_ASYNC_TCP_PRIORITY=10
|
-D CONFIG_ASYNC_TCP_PRIORITY=10
|
||||||
|
@@ -287,7 +287,6 @@ AsyncWebSocketClient::AsyncWebSocketClient(AsyncWebServerRequest* request, Async
|
|||||||
_client->onTimeout([](void* r, AsyncClient* c, uint32_t time) { (void)c; ((AsyncWebSocketClient*)(r))->_onTimeout(time); }, this);
|
_client->onTimeout([](void* r, AsyncClient* c, uint32_t time) { (void)c; ((AsyncWebSocketClient*)(r))->_onTimeout(time); }, this);
|
||||||
_client->onData([](void* r, AsyncClient* c, void* buf, size_t len) { (void)c; ((AsyncWebSocketClient*)(r))->_onData(buf, len); }, this);
|
_client->onData([](void* r, AsyncClient* c, void* buf, size_t len) { (void)c; ((AsyncWebSocketClient*)(r))->_onData(buf, len); }, this);
|
||||||
_client->onPoll([](void* r, AsyncClient* c) { (void)c; ((AsyncWebSocketClient*)(r))->_onPoll(); }, this);
|
_client->onPoll([](void* r, AsyncClient* c) { (void)c; ((AsyncWebSocketClient*)(r))->_onPoll(); }, this);
|
||||||
_server->_handleEvent(this, WS_EVT_CONNECT, request, NULL, 0);
|
|
||||||
delete request;
|
delete request;
|
||||||
memset(&_pinfo, 0, sizeof(_pinfo));
|
memset(&_pinfo, 0, sizeof(_pinfo));
|
||||||
}
|
}
|
||||||
@@ -781,6 +780,7 @@ void AsyncWebSocket::_handleEvent(AsyncWebSocketClient* client, AwsEventType typ
|
|||||||
|
|
||||||
AsyncWebSocketClient* AsyncWebSocket::_newClient(AsyncWebServerRequest* request) {
|
AsyncWebSocketClient* AsyncWebSocket::_newClient(AsyncWebServerRequest* request) {
|
||||||
_clients.emplace_back(request, this);
|
_clients.emplace_back(request, this);
|
||||||
|
_handleEvent(&_clients.back(), WS_EVT_CONNECT, request, NULL, 0);
|
||||||
return &_clients.back();
|
return &_clients.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user