Skip to content
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

Used any_io_executor as the base of predefined mqtt protocol. #104

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions example/ep_cpp20coro_mqtt_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
namespace as = boost::asio;
namespace am = async_mqtt;

template <typename Executor>
as::awaitable<void>
proc(Executor exe, std::string_view host, std::string_view port) {
proc(std::string_view host, std::string_view port) {
auto exe = co_await as::this_coro::executor;
as::ip::tcp::socket resolve_sock{exe};
as::ip::tcp::resolver res{exe};
auto amep = am::endpoint<am::role::client, am::protocol::mqtt>::create(
Expand Down Expand Up @@ -183,6 +183,6 @@ int main(int argc, char* argv[]) {
return -1;
}
as::io_context ioc;
as::co_spawn(ioc, proc(ioc.get_executor(), argv[1], argv[2]), as::detached);
as::co_spawn(ioc.get_executor(), proc(argv[1], argv[2]), as::detached);
ioc.run();
}
20 changes: 17 additions & 3 deletions include/async_mqtt/predefined_underlying_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ namespace protocol {
/**
* @breif Type alias of Boost.Asio TCP socket
*/
using mqtt = as::basic_stream_socket<as::ip::tcp, as::io_context::executor_type>;
using mqtt = as::basic_stream_socket<as::ip::tcp, as::any_io_executor>;

#if defined(ASYNC_MQTT_USE_WS)

namespace detail {

using mqtt_beast_workaround = as::basic_stream_socket<as::ip::tcp, as::io_context::executor_type>;

} // namespace detail

/**
* @breif Type alias of Boost.Beast WebScoket
*/
using ws = bs::websocket::stream<mqtt>;
using ws = bs::websocket::stream<detail::mqtt_beast_workaround>;
#endif //defined(ASYNC_MQTT_USE_WS)

} // namespace procotol
Expand All @@ -49,10 +56,17 @@ namespace protocol {
using mqtts = tls::stream<mqtt>;

#if defined(ASYNC_MQTT_USE_WS)

namespace detail {

using mqtts_beast_workaround = tls::stream<mqtt_beast_workaround>;

} // namespace detail

/**
* @breif Type alias of Boost.Beast WebSocket on TLS stream
*/
using wss = bs::websocket::stream<mqtts>;
using wss = bs::websocket::stream<detail::mqtts_beast_workaround>;
#endif // defined(ASYNC_MQTT_USE_WS)


Expand Down