Giter Site home page Giter Site logo

Comments (2)

redboltz avatar redboltz commented on July 30, 2024

props is std::vector<async_mqtt::property_varinat>, so p is a reference of aync_mqtt::property_variant.
property_variant has the following interface:
https://redboltz.github.io/async_mqtt/doc/latest/html/classasync__mqtt_1_1property__variant.html

You have two choices. One is using visit() function. The other is get() function.

1

Here is visit() code:

for (auto const& prop : props) {
prop.visit(
overload {
[&](property::session_expiry_interval const& v) {
if (v.val() != 0) {
session_expiry_interval.emplace(std::chrono::seconds(v.val()));
}
},
[&](property::request_response_information const& v) {
response_topic_requested = v.val();
},
[&](auto const&) {}
}
);

2

get() is used with template argument.

auto const& sei_prop = p.get<async_mqtt::property::session_expiry_interval>();
sei_prop.val(); // access

from async_mqtt.

magni-mar avatar magni-mar commented on July 30, 2024

thank you for a quick response, I will use the second one as it is more fitting for my use case.

from async_mqtt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.