MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / broadcastEvent

Method broadcastEvent

app/src/API/Server.cpp:222–235  ·  view source on GitHub ↗

* @brief Broadcasts a lifecycle event JSON object to all connected API clients. */

Source from the content-addressed store, hash-verified

220 * @brief Broadcasts a lifecycle event JSON object to all connected API clients.
221 */
222void API::ServerWorker::broadcastEvent(const QJsonObject& event)
223{
224 Q_ASSERT(!event.isEmpty());
225
226 if (m_sockets.isEmpty())
227 return;
228
229 const QJsonDocument document(event);
230 const auto json = document.toJson(QJsonDocument::Compact) + "\n";
231
232 for (auto* socket : std::as_const(m_sockets))
233 if (socket && socket->isWritable())
234 socket->write(json);
235}
236
237/**
238 * @brief Handles incoming data from a socket (worker thread)

Callers

nothing calls this directly

Calls 4

isEmptyMethod · 0.80
toJsonMethod · 0.45
isWritableMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected