-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supporting async when filtering. #42
Comments
both recv() is async. I'm not sure what are you asking. Could you elaborate your question? |
Here is a little usage document https://github.com/redboltz/async_mqtt#control-packet-type-filter |
@magni-mar is meaning the usage of |
@jbbjarnason , thank you for the comment. Now, I understand the issue is compiling error, and the error seems to be caused by direct token() call. |
I belive that I fixed the issue. Coud you try #44 ? |
Unfortunately this doesn't work. I am calling the function like this: co_await mqtt_client_->recv(async_mqtt::filter::match, {async_mqtt::control_packet_type::connack}, asio::use_awaitable); and these are the compiler errors: ====================[ Build | mqtt-broadcaster | ci-clang-release ]=============
/usr/bin/cmake --build /home/magni-the-developer/Documents/framework/build/ci-clang-release --target mqtt-broadcaster -j 30
[1/2] Building CXX object exes/mqtt-broadcaster/CMakeFiles/mqtt-broadcaster.dir/src/main.cpp.o
FAILED: exes/mqtt-broadcaster/CMakeFiles/mqtt-broadcaster.dir/src/main.cpp.o
/usr/bin/clang++-16 -DASYNC_MQTT_USE_LOG -DONLY_C_LOCALE=0 -DUNITS_DOWNCAST_MODE=1 -I/home/magni-the-developer/Documents/framework/exes/mqtt-broadcaster/inc -I/home/magni-the-developer/Documents/framework/libs/progbase/inc/public -I/home/magni-the-developer/Documents/framework/libs/logger/inc/public -I/home/magni-the-developer/Documents/framework/libs/stx/inc/public -I/home/magni-the-developer/Documents/framework/libs/ipc/inc/public -I/home/magni-the-developer/Documents/framework/libs/dbus_util/inc/public -I/home/magni-the-developer/Documents/framework/libs/configure_options/inc/public -I/home/magni-the-developer/Documents/framework/libs/operation_mode/inc/public -I/home/magni-the-developer/Documents/framework/libs/confman/inc/public -isystem /home/magni-the-developer/Documents/framework/vcpkg-sysroot-clang/x64-linux-clang/include -isystem /home/magni-the-developer/Documents/framework/vcpkg-sysroot-clang/x64-linux-clang/lib/pkgconfig/../../include -isystem /home/magni-the-developer/Documents/framework/vcpkg-sysroot-clang/x64-linux-clang/lib/pkgconfig/../../include/libmount -isystem /home/magni-the-developer/Documents/framework/vcpkg-sysroot-clang/x64-linux-clang/lib/pkgconfig/../../include/blkid -stdlib=libc++ -O3 -DNDEBUG -std=gnu++2b -fcolor-diagnostics -fuse-ld=lld -flto=thin -fvisibility=hidden -fvisibility-inlines-hidden -Weverything -Werror -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-pre-c++14-compat -Wno-pre-c++17-compat -Wno-pre-c++20-compat-pedantic -Wno-c++20-compat -Wno-unused-parameter -Wno-padded -Wno-unused-command-line-argument -Wno-missing-braces -MD -MT exes/mqtt-broadcaster/CMakeFiles/mqtt-broadcaster.dir/src/main.cpp.o -MF exes/mqtt-broadcaster/CMakeFiles/mqtt-broadcaster.dir/src/main.cpp.o.d -o exes/mqtt-broadcaster/CMakeFiles/mqtt-broadcaster.dir/src/main.cpp.o -c /home/magni-the-developer/Documents/framework/exes/mqtt-broadcaster/src/main.cpp
In file included from /home/magni-the-developer/Documents/framework/exes/mqtt-broadcaster/src/main.cpp:1:
In file included from /home/magni-the-developer/Documents/framework/vcpkg-sysroot-clang/x64-linux-clang/include/async_mqtt/all.hpp:13:
/home/magni-the-developer/Documents/framework/vcpkg-sysroot-clang/x64-linux-clang/include/async_mqtt/endpoint.hpp:442:25: error: type 'boost::asio::use_awaitable_t<>' does not provide a call operator
token(force_move(pv));
^~~~~
/home/magni-the-developer/Documents/framework/exes/mqtt-broadcaster/inc/mqtt_broadcaster.hpp:123:33: note: in instantiation of function template specialization 'async_mqtt::basic_endpoint<async_mqtt::role::client, 2, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>>>::recv<const boost::asio::use_awaitable_t<> &>' requested here
co_await mqtt_client_->recv(async_mqtt::filter::match, {async_mqtt::control_packet_type::connack}, asio::use_awaitable);
^
/home/magni-the-developer/Documents/framework/exes/mqtt-broadcaster/inc/mqtt_broadcaster.hpp:49:44: note: in instantiation of member function 'mqtt_broadcaster<tfc::ipc_ruler::ipc_manager_client &, sdbusplus::bus::match::match, async_mqtt::basic_endpoint<async_mqtt::role::client, 2, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>>>>::connect_to_broker' requested here
asio::co_spawn(mqtt_client_->strand(), connect_to_broker(), asio::detached);
^
/home/magni-the-developer/Documents/framework/exes/mqtt-broadcaster/src/main.cpp:32:7: note: in instantiation of member function 'mqtt_broadcaster<tfc::ipc_ruler::ipc_manager_client &, sdbusplus::bus::match::match, async_mqtt::basic_endpoint<async_mqtt::role::client, 2, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>>>>::mqtt_broadcaster' requested here
application(ctx, mqtt_host, mqtt_port, mqtt_username, mqtt_password, ipc_client, mqtt_client);
^
In file included from /home/magni-the-developer/Documents/framework/exes/mqtt-broadcaster/src/main.cpp:1:
In file included from /home/magni-the-developer/Documents/framework/vcpkg-sysroot-clang/x64-linux-clang/include/async_mqtt/all.hpp:13:
/home/magni-the-developer/Documents/framework/vcpkg-sysroot-clang/x64-linux-clang/include/async_mqtt/endpoint.hpp:442:25: error: type 'boost::asio::use_awaitable_t<>' does not provide a call operator
token(force_move(pv));
^~~~~
/home/magni-the-developer/Documents/framework/vcpkg-sysroot-clang/x64-linux-clang/include/async_mqtt/endpoint.hpp:403:16: note: in instantiation of function template specialization 'async_mqtt::basic_endpoint<async_mqtt::role::client, 2, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>>>::recv<boost::asio::use_awaitable_t<>>' requested here
return recv(filter::match, force_move(types), std::forward<CompletionToken>(token));
^
/home/magni-the-developer/Documents/framework/vcpkg-sysroot-clang/x64-linux-clang/include/async_mqtt/endpoint.hpp:439:25: note: in instantiation of function template specialization 'async_mqtt::basic_endpoint<async_mqtt::role::client, 2, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>>>::recv<boost::asio::use_awaitable_t<>>' requested here
recv(force_move(types), force_move(token));
^
/home/magni-the-developer/Documents/framework/exes/mqtt-broadcaster/inc/mqtt_broadcaster.hpp:123:33: note: in instantiation of function template specialization 'async_mqtt::basic_endpoint<async_mqtt::role::client, 2, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>>>::recv<const boost::asio::use_awaitable_t<> &>' requested here
co_await mqtt_client_->recv(async_mqtt::filter::match, {async_mqtt::control_packet_type::connack}, asio::use_awaitable);
^
/home/magni-the-developer/Documents/framework/exes/mqtt-broadcaster/inc/mqtt_broadcaster.hpp:49:44: note: in instantiation of member function 'mqtt_broadcaster<tfc::ipc_ruler::ipc_manager_client &, sdbusplus::bus::match::match, async_mqtt::basic_endpoint<async_mqtt::role::client, 2, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>>>>::connect_to_broker' requested here
asio::co_spawn(mqtt_client_->strand(), connect_to_broker(), asio::detached);
^
/home/magni-the-developer/Documents/framework/exes/mqtt-broadcaster/src/main.cpp:32:7: note: in instantiation of member function 'mqtt_broadcaster<tfc::ipc_ruler::ipc_manager_client &, sdbusplus::bus::match::match, async_mqtt::basic_endpoint<async_mqtt::role::client, 2, boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>>>>::mqtt_broadcaster' requested here
application(ctx, mqtt_host, mqtt_port, mqtt_username, mqtt_password, ipc_client, mqtt_client);
^
2 errors generated.
ninja: build stopped: subcommand failed. |
Could you check your commit hash? It should be c2614a0 |
My mistake, I copy/pasted the code to the wrong file location just for testing. This fix works. Thank you for your quick response. |
Ok, I will merge it. |
recv( filter fil, std::set<control_packet_type> types, CompletionToken&& token ) {
I am trying to filter received packages by their type and was wondering why this function doesn't support async as the normal recv function without filtering does support async.
recv( CompletionToken&& token ) {
The text was updated successfully, but these errors were encountered: