Skip to content

Commit

Permalink
Tweaks: ws client queuelength check for lossy calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ewowi committed Jan 23, 2024
1 parent fe6eb91 commit 5c8d4b2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/App/AppModPreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ class AppModPreview:public SysModule {
// web->addResponse(var["id"], "comment", "Click to enlarge");
}, nullptr, [](JsonObject var, uint8_t rowNr) { //loopFun


xSemaphoreTake(web->wsMutex, portMAX_DELAY);

web->wsSendBytesCounter++;

SysModWeb::ws->cleanupClients();

uint8_t* buffer;
Expand All @@ -56,7 +58,7 @@ class AppModPreview:public SysModule {
var["interval"] = max(ledsV.nrOfLedsP * SysModWeb::ws->count()/200, 16U)*10; //interval in ms * 10, not too fast //from cs to ms

for (auto client:SysModWeb::ws->getClients()) {
// if (client->status() == WS_CONNECTED && !client->queueIsFull() && client->queueLength()<=3) //lossy
if (client->status() == WS_CONNECTED && !client->queueIsFull() && client->queueLength() <= WS_MAX_QUEUED_MESSAGES / 2) //lossy
client->binary(wsBuf);
// else {
// web->clientsChanged = true; tbd: changed also if full status changes
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void SysModModel::setValueLossy(const char * id, const char * format, ...) {

bool isOk = true;
for (auto client:SysModWeb::ws->getClients()) {
if (client->status() != WS_CONNECTED || client->queueIsFull() || client->queueLength()>3) //lossy
if (client->status() != WS_CONNECTED || client->queueIsFull() || client->queueLength()>WS_MAX_QUEUED_MESSAGES/2) //lossy
isOk = false;
}
if (isOk)
Expand Down
4 changes: 3 additions & 1 deletion src/Sys/SysModPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ void SysModPins::setup() {

xSemaphoreTake(web->wsMutex, portMAX_DELAY);

web->wsSendBytesCounter++;

SysModWeb::ws->cleanupClients();

uint8_t* buffer;
Expand All @@ -96,7 +98,7 @@ void SysModPins::setup() {
var["interval"] = 10*10*10; //every 10 sec from cs to ms

for (auto client:SysModWeb::ws->getClients()) {
// if (client->status() == WS_CONNECTED && !client->queueIsFull() && client->queueLength()<=3) //lossy
if (client->status() == WS_CONNECTED && !client->queueIsFull() && client->queueLength() <= WS_MAX_QUEUED_MESSAGES / 2) //lossy
client->binary(wsBuf);
// else {
// web->clientsChanged = true; tbd: changed also if full status changes
Expand Down

0 comments on commit 5c8d4b2

Please sign in to comment.