forked from me-no-dev/ESPAsyncWebServer
Add EventSource::count()
This commit is contained in:
@@ -243,6 +243,17 @@ void AsyncEventSource::send(const char *message, const char *event, uint32_t id,
|
||||
}
|
||||
}
|
||||
|
||||
size_t AsyncEventSource::count(){
|
||||
size_t i = 0;
|
||||
AsyncEventSourceClient * c = _clients;
|
||||
while(c != NULL){
|
||||
if(c->connected())
|
||||
i++;
|
||||
c = c->next;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
bool AsyncEventSource::canHandle(AsyncWebServerRequest *request){
|
||||
if(request->method() != HTTP_GET || !request->url().equals(_url))
|
||||
return false;
|
||||
|
@@ -66,6 +66,7 @@ class AsyncEventSource: public AsyncWebHandler {
|
||||
void close();
|
||||
void onConnect(ArEventHandlerFunction cb);
|
||||
void send(const char *message, const char *event=NULL, uint32_t id=0, uint32_t reconnect=0);
|
||||
size_t count(); //number clinets connected
|
||||
|
||||
//system callbacks (do not call)
|
||||
void _addClient(AsyncEventSourceClient * client);
|
||||
|
Reference in New Issue
Block a user