Add EventSource::count()

This commit is contained in:
Me No Dev
2016-06-30 11:26:20 +03:00
parent 5137dbe0bf
commit b8ba1c885b
2 changed files with 12 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);