* @brief Publishes a payload and increments the stats counters. */
| 467 | * @brief Publishes a payload and increments the stats counters. |
| 468 | */ |
| 469 | void MQTT::PublisherWorker::publishAndCount(const QMqttTopicName& topic, const QByteArray& payload) |
| 470 | { |
| 471 | const auto id = m_client->publish(topic, payload); |
| 472 | qCDebug(lcMqttPub) << "publish topic=" << topic.name() << "size=" << payload.size() << "id=" << id |
| 473 | << "preview=" << payload.left(80); |
| 474 | |
| 475 | if (id < 0) { |
| 476 | qCWarning(lcMqttPub) << "publish returned -1 for topic" << topic.name(); |
| 477 | return; |
| 478 | } |
| 479 | |
| 480 | if (m_messagesSent) |
| 481 | m_messagesSent->fetch_add(1, std::memory_order_relaxed); |
| 482 | |
| 483 | if (m_bytesSent) |
| 484 | m_bytesSent->fetch_add(static_cast<quint64>(payload.size()), std::memory_order_relaxed); |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * @brief Applies a fresh broker config snapshot. Reconnects when broker-affecting fields change. |