7#if !defined(ASYNC_MQTT_UTIL_TOPIC_ALIAS_RECV_HPP)
8#define ASYNC_MQTT_UTIL_TOPIC_ALIAS_RECV_HPP
12#include <unordered_map>
15#include <boost/assert.hpp>
16#include <boost/multi_index_container.hpp>
17#include <boost/multi_index/ordered_index.hpp>
18#include <boost/multi_index/key.hpp>
20#include <async_mqtt/util/log.hpp>
21#include <async_mqtt/util/move.hpp>
22#include <async_mqtt/packet/property.hpp>
26namespace mi = boost::multi_index;
28class topic_alias_recv {
34 ASYNC_MQTT_LOG(
"mqtt_impl",
trace)
35 << ASYNC_MQTT_ADD_VALUE(address,
this)
36 <<
"topic_alias_recv insert"
38 <<
" alias:" << alias;
39 BOOST_ASSERT(!topic.empty() && alias >= min_ && alias <= max_);
40 auto it = aliases_.lower_bound(alias);
41 if (it == aliases_.end() || it->alias != alias) {
42 aliases_.emplace_hint(it, std::string(topic), alias);
48 e.topic = std::string{topic};
50 [](
auto&) { BOOST_ASSERT(
false); }
56 if (alias >= min_ && alias <= max_) {
58 auto it = aliases_.find(alias);
59 if (it != aliases_.end()) topic = it->topic;
61 ASYNC_MQTT_LOG(
"mqtt_impl",
info)
62 << ASYNC_MQTT_ADD_VALUE(address,
this)
63 <<
"find_topic_by_alias"
65 <<
" topic:" << topic;
73 ASYNC_MQTT_LOG(
"mqtt_impl",
info)
74 << ASYNC_MQTT_ADD_VALUE(address,
this)
75 <<
"clear_topic_alias";
87 : topic{force_move(topic)}, alias{alias} {}
92 using mi_topic_alias = mi::multi_index_container<
96 mi::key<&entry::alias>
101 mi_topic_alias aliases_;
@ trace
trace level for detaied behavior and reporting issue
@ info
info level api call is output
std::uint16_t topic_alias_type
type of the topic alias value
Definition property.hpp:81