Giter Site home page Giter Site logo

Message Poller about async_mqtt HOT 3 CLOSED

redboltz avatar redboltz commented on July 30, 2024
Message Poller

from async_mqtt.

Comments (3)

redboltz avatar redboltz commented on July 30, 2024

You can call the next recv() to get meeage().
Here is client_cli.cpp code:

// Recv loop
while (true) {
yield ep_.recv(*this);
if (pv) {
pv.visit(
am::overload {
[&](am::v3_1_1::publish_packet const& p) {
std::cout << color_recv;
std::cout << p << std::endl;
std::cout << " payload:";
for (auto const& e : p.payload()) {
std::cout << am::json_like_out(e);
}
std::cout << std::endl;
std::cout << color_none;
},
[&](am::v5::publish_packet const& p) {
std::cout << color_recv;
std::cout << p << std::endl;
std::cout << " payload:";
for (auto const& e : p.payload()) {
std::cout << am::json_like_out(e);
}
std::cout << std::endl;
std::cout << color_none;
},
[](auto const& p) {
std::cout << color_recv;
std::cout << p << std::endl;
std::cout << color_none;
}
}
);
}
else {
std::cout << color_recv;
std::cout
<< "recv error:"
<< pv.get<am::system_error>().what()
<< std::endl;
std::cout << color_none;
return;
}
}

It uses stackless coroutine. If you use callback approach, then call recv() the last part of recv() callback instead of the loop.

NOTE: It is not a polling, it is still event driven.

from async_mqtt.

redboltz avatar redboltz commented on July 30, 2024

If you still have the problem, feel free to reopen the issue.

from async_mqtt.

elia-sysdesign avatar elia-sysdesign commented on July 30, 2024

Thank you for the quick response.
I will give it a go and let you know.

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.