From 368c5b04b3b59f9bb26f2e5d652a51c9abc1205b Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Fri, 23 Aug 2024 13:50:34 +0200 Subject: [PATCH] b simulator + websocket simulator changed_UI_items returning null instead of {} cleanup of process broadcast discard on empty update --- tools/simulators.cpp | 4 ++-- tools/websocket.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/simulators.cpp b/tools/simulators.cpp index b136224..31679f2 100644 --- a/tools/simulators.cpp +++ b/tools/simulators.cpp @@ -85,11 +85,11 @@ json Simulators::changed_UI_items() { if (this->m_simulators.empty()) { - return json(); + return "{}"_json; } if (this->m_current_simulator.empty()) { - return json(); + return "{}"_json; } json after = this->m_simulators.at(m_current_simulator)->get_UI_items(); diff --git a/tools/websocket.cpp b/tools/websocket.cpp index fa02813..0db6d45 100644 --- a/tools/websocket.cpp +++ b/tools/websocket.cpp @@ -127,7 +127,10 @@ void Websocket::process_broadcast() } } std::string update = m_on_update(); - if (!update.empty() && update != "{}") + if (update.empty() || update == "{}") + { + continue; + } { std::lock_guard guard(m_connection_lock); for (auto it = m_connections.begin(); it != m_connections.end(); ++it) {