* @brief Broadcasts a lifecycle event JSON object to all connected API clients. */
| 220 | * @brief Broadcasts a lifecycle event JSON object to all connected API clients. |
| 221 | */ |
| 222 | void 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) |
nothing calls this directly
no test coverage detected