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

Method processItems

app/src/API/Server.cpp:284–306  ·  view source on GitHub ↗

* @brief Processes frames by serializing them to JSON and writing to sockets */

Source from the content-addressed store, hash-verified

282 * @brief Processes frames by serializing them to JSON and writing to sockets
283 */
284void API::ServerWorker::processItems(const std::vector<DataModel::TimestampedFramePtr>& items)
285{
286 Q_ASSERT(!items.empty());
287
288 if (items.empty() || m_sockets.isEmpty())
289 return;
290
291 QJsonArray array;
292 for (const auto& timestampedFrame : items) {
293 QJsonObject object;
294 object.insert(QStringLiteral("data"), serialize(timestampedFrame->data));
295 array.append(object);
296 }
297
298 QJsonObject object;
299 object.insert(QStringLiteral("frames"), array);
300 const QJsonDocument document(object);
301 const auto json = document.toJson(QJsonDocument::Compact) + "\n";
302
303 for (auto* socket : std::as_const(m_sockets))
304 if (socket && socket->isWritable())
305 socket->write(json);
306}
307
308//--------------------------------------------------------------------------------------------------
309// Server implementation

Callers

nothing calls this directly

Calls 7

serializeFunction · 0.85
emptyMethod · 0.80
isEmptyMethod · 0.80
appendMethod · 0.45
toJsonMethod · 0.45
isWritableMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected