thread-safe client

Reviewers: ivica

Reviewed By: ivica

Subscribers: korina

Differential Revision: https://repo.mireo.local/D26864
This commit is contained in:
Bruno Iljazovic
2023-12-07 12:18:28 +01:00
parent e849166599
commit e0a0bafbf1
8 changed files with 68 additions and 10 deletions

View File

@@ -61,9 +61,18 @@ public:
template <typename Prop>
decltype(auto) connack_prop(Prop p) {
std::shared_lock reader_lock(_mqtt_context.ca_mtx);
return _mqtt_context.ca_props[p];
}
template <typename Prop0, typename ...Props>
decltype(auto) connack_props(Prop0 p0, Props ...props) {
std::shared_lock reader_lock(_mqtt_context.ca_mtx);
return std::make_tuple(
_mqtt_context.ca_props[p0], _mqtt_context.ca_props[props]...
);
}
void credentials(
std::string client_id,
std::string username = "", std::string password = ""
@@ -109,9 +118,18 @@ public:
template <typename Prop>
decltype(auto) connack_prop(Prop p) {
std::shared_lock reader_lock(_mqtt_context.ca_mtx);
return _mqtt_context.ca_props[p];
}
template <typename Prop0, typename ...Props>
decltype(auto) connack_props(Prop0 p0, Props ...props) {
std::shared_lock reader_lock(_mqtt_context.ca_mtx);
return std::make_tuple(
_mqtt_context.ca_props[p0], _mqtt_context.ca_props[props]...
);
}
void credentials(
std::string client_id,
std::string username = "", std::string password = ""
@@ -243,6 +261,11 @@ public:
return _stream_context.connack_prop(p);
}
template <typename Prop0, typename ...Props>
decltype(auto) connack_props(Prop0 p0, Props ...props) {
return _stream_context.connack_props(p0, props...);
}
void run() {
_stream.open();
_rec_channel.reset();