From a0ff86e76d56188221f362dac0cd4e8354de65ca Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Tue, 1 Oct 2024 10:55:14 +0200 Subject: [PATCH] Fixed const getter which should be non const to access client api --- examples/SimpleServer/SimpleServer.ino | 4 ++++ src/AsyncWebSocket.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/SimpleServer/SimpleServer.ino b/examples/SimpleServer/SimpleServer.ino index b3e3281..899c77d 100644 --- a/examples/SimpleServer/SimpleServer.ino +++ b/examples/SimpleServer/SimpleServer.ino @@ -463,6 +463,10 @@ void loop() { } if (now - lastWS >= deltaWS) { ws.printfAll("kp%.4f", (10.0 / 3.0)); + // ws.getClients + for (auto& client : ws.getClients()) { + client.text("kp%.4f", (10.0 / 3.0)); + } lastWS = millis(); } } diff --git a/src/AsyncWebSocket.h b/src/AsyncWebSocket.h index 2fe14d1..1da3d15 100644 --- a/src/AsyncWebSocket.h +++ b/src/AsyncWebSocket.h @@ -351,7 +351,7 @@ class AsyncWebSocket : public AsyncWebHandler { AsyncWebSocketMessageBuffer* makeBuffer(size_t size = 0); AsyncWebSocketMessageBuffer* makeBuffer(const uint8_t* data, size_t size); - const std::list& getClients() const { return _clients; } + std::list& getClients() { return _clients; } }; // WebServer response to authenticate the socket and detach the tcp client from the web server request