Skip to content
This repository was archived by the owner on Jan 21, 2025. It is now read-only.

Commit 0554cee

Browse files
committed
Added example to demo that fix #177 fixes issue #176
1 parent 2a26a97 commit 0554cee

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/SimpleServer/SimpleServer.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ AsyncMiddlewareFunction complexAuth([](AsyncWebServerRequest* request, ArMiddlew
147147

148148
AuthorizationMiddleware authz([](AsyncWebServerRequest* request) { return request->getAttribute("role") == "staff"; });
149149

150+
int wsClients = 0;
151+
150152
/////////////////////////////////////////////////////////////////////////////////////////////////////
151153

152154
const char* PARAM_MESSAGE PROGMEM = "message";
@@ -646,10 +648,14 @@ void setup() {
646648
ws.onEvent([](AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len) {
647649
(void)len;
648650
if (type == WS_EVT_CONNECT) {
651+
wsClients++;
652+
ws.textAll("new client connected");
649653
Serial.println("ws connect");
650654
client->setCloseClientOnQueueFull(false);
651655
client->ping();
652656
} else if (type == WS_EVT_DISCONNECT) {
657+
wsClients--;
658+
ws.textAll("client disconnected");
653659
Serial.println("ws disconnect");
654660
} else if (type == WS_EVT_ERROR) {
655661
Serial.println("ws error");

0 commit comments

Comments
 (0)