1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-22 04:00:55 +00:00

Fixed bug that caused a crash when sending graphpoint updates to multiple browsers.

This commit is contained in:
Martin Mueller 2022-09-22 09:36:12 -04:00
parent a18254b16b
commit 1595b3bd04

View File

@ -857,10 +857,12 @@ void ESPUIClass::clearGraph(uint16_t id, int clientId) { }
void ESPUIClass::addGraphPoint(uint16_t id, int nValue, int clientId) void ESPUIClass::addGraphPoint(uint16_t id, int nValue, int clientId)
{ {
do // once
{
Control* control = getControl(id); Control* control = getControl(id);
if (!control) if (!control)
{ {
return; break;
} }
DynamicJsonDocument document(jsonUpdateDocumentSize); DynamicJsonDocument document(jsonUpdateDocumentSize);
@ -869,7 +871,10 @@ void ESPUIClass::addGraphPoint(uint16_t id, int nValue, int clientId)
root[F("type")] = (int)ControlType::GraphPoint; root[F("type")] = (int)ControlType::GraphPoint;
root[F("value")] = nValue; root[F("value")] = nValue;
root[F("id")] = control->id; root[F("id")] = control->id;
SendJsonDocToWebSocket(document, clientId); SendJsonDocToWebSocket(document, clientId);
} while(false);
} }
bool ESPUIClass::SendJsonDocToWebSocket(ArduinoJson::DynamicJsonDocument& document, uint16_t clientId) bool ESPUIClass::SendJsonDocToWebSocket(ArduinoJson::DynamicJsonDocument& document, uint16_t clientId)
@ -885,9 +890,9 @@ bool ESPUIClass::SendJsonDocToWebSocket(ArduinoJson::DynamicJsonDocument& docume
} }
else else
{ {
for(auto& CurrentClient : MapOfClients) for(auto CurrentClient : MapOfClients)
{ {
Response |= MapOfClients[clientId]->SendJsonDocToWebSocket(document); Response |= CurrentClient.second->SendJsonDocToWebSocket(document);
} }
} }