36 lines
813 B
C++
36 lines
813 B
C++
#pragma once
|
|
|
|
#include <boost/asio/awaitable.hpp>
|
|
|
|
#include <memory>
|
|
#include <string_view>
|
|
|
|
namespace boost::json {
|
|
class value;
|
|
}
|
|
|
|
namespace boost::asio {
|
|
class any_io_executor;
|
|
}
|
|
|
|
namespace ranczo {
|
|
|
|
class AsyncMqttClient {
|
|
public:
|
|
template < typename T >
|
|
using awaitable = boost::asio::awaitable< T >;
|
|
using executor = boost::asio::any_io_executor;
|
|
|
|
struct AsyncMqttClientImpl;
|
|
std::unique_ptr< AsyncMqttClientImpl > _impl;
|
|
|
|
AsyncMqttClient(const executor & executor);
|
|
~AsyncMqttClient();
|
|
|
|
awaitable< bool > subscribe(std::string_view topic, std::function< void(const boost::json::value & value) >);
|
|
bool add_subscribtion(std::string_view topic, std::function< void(const boost::json::value & value) >cb);
|
|
awaitable< void > listen() const;
|
|
};
|
|
|
|
} // namespace ranczo
|