mirror of
https://github.com/me-no-dev/ESPAsyncWebServer.git
synced 2026-01-27 09:12:18 +01:00
Allows to check queue status (#411)
This commit is contained in:
@@ -544,6 +544,11 @@ void AsyncWebSocketClient::_runQueue(){
|
||||
}
|
||||
}
|
||||
|
||||
bool AsyncWebSocketClient::queueIsFull(){
|
||||
if((_messageQueue.length() >= WS_MAX_QUEUED_MESSAGES) || (_status != WS_CONNECTED) ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void AsyncWebSocketClient::_queueMessage(AsyncWebSocketMessage *dataMessage){
|
||||
if(dataMessage == NULL)
|
||||
return;
|
||||
@@ -876,6 +881,20 @@ void AsyncWebSocket::_handleDisconnect(AsyncWebSocketClient * client){
|
||||
});
|
||||
}
|
||||
|
||||
bool AsyncWebSocket::availableForWriteAll(){
|
||||
for(const auto& c: _clients){
|
||||
if(c->queueIsFull()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AsyncWebSocket::availableForWrite(uint32_t id){
|
||||
for(const auto& c: _clients){
|
||||
if(c->queueIsFull() && (c->id() == id )) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t AsyncWebSocket::count() const {
|
||||
return _clients.count_if([](AsyncWebSocketClient * c){
|
||||
return c->status() == WS_CONNECTED;
|
||||
|
||||
Reference in New Issue
Block a user