ranczo-io/services/floorheat_svc/mqtt_client.hpp
2025-08-05 14:45:02 +02:00

48 lines
1019 B
C++

#pragma once
#include <config.hpp>
#include <memory>
#include <optional>
#include <string_view>
namespace boost::json {
class value;
}
namespace boost::asio {
class any_io_executor;
}
using executor = boost::asio::any_io_executor;
namespace ranczo {
class AsyncMqttClient {
public:
struct CallbackData {
/* topic */
std::string_view topic;
/* response topic */
std::optional<std::string_view> responseTopic;
/* value assosiated to request */
const boost::json::value & value;
/* memory_resource of client */
// TBD
};
struct AsyncMqttClientImpl;
std::unique_ptr< AsyncMqttClientImpl > _impl;
AsyncMqttClient(const executor & executor);
~AsyncMqttClient();
awaitable_expected< void > subscribe(std::string_view topic, std::function< awaitable_expected< void >(const boost::json::value & value) >) noexcept;
awaitable_expected< void > listen() const noexcept;
};
} // namespace ranczo