7 #if !defined(MQTT_ASYNC_CLIENT_HPP)
8 #define MQTT_ASYNC_CLIENT_HPP
17 template <
typename Socket, std::
size_t PacketIdBytes = 2>
27 template<
typename ... Args>
39 friend std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
49 friend std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, null_strand>>>>
52 #if defined(MQTT_USE_WS)
62 friend std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
63 make_async_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path,
protocol_version version);
73 friend std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, null_strand>>>>
74 make_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path,
protocol_version version);
77 #if defined(MQTT_USE_TLS)
85 friend std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
86 make_tls_async_client(as::io_context& ioc, std::string host, std::string port,
protocol_version version);
95 friend std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>,
null_strand>>>>
96 make_tls_async_client_no_strand(as::io_context& ioc, std::string host, std::string port,
protocol_version version);
98 #if defined(MQTT_USE_WS)
108 friend std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
109 make_tls_async_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path,
protocol_version version);
119 friend std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>,
null_strand>>>>
120 make_tls_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path,
protocol_version version);
131 friend std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
141 friend std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
144 #if defined(MQTT_USE_WS)
154 friend std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
155 make_async_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path,
protocol_version version);
165 friend std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
166 make_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path,
protocol_version version);
169 #if defined(MQTT_USE_TLS)
177 friend std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
178 make_tls_async_client_32(as::io_context& ioc, std::string host, std::string port,
protocol_version version);
187 friend std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>,
null_strand>, 4>>>
188 make_tls_async_client_no_strand_32(as::io_context& ioc, std::string host, std::string port,
protocol_version version);
190 #if defined(MQTT_USE_WS)
200 friend std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
201 make_tls_async_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path,
protocol_version version);
211 friend std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>,
null_strand>, 4>>>
212 make_tls_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path,
protocol_version version);
255 #
if defined(MQTT_USE_WS)
256 std::string path =
"/",
262 #if defined(MQTT_USE_WS)
273 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
276 return std::make_shared<callable_overlay<async_client_t>>(
277 async_client_t::constructor_access(),
281 #if defined(MQTT_USE_WS)
288 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
293 std::to_string(port),
298 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, null_strand>>>>
301 return std::make_shared<callable_overlay<async_client_t>>(
302 async_client_t::constructor_access(),
306 #if defined(MQTT_USE_WS)
313 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, null_strand>>>>
318 std::to_string(port),
323 #if defined(MQTT_USE_WS)
325 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
327 using async_client_t = async_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>>;
328 return std::make_shared<callable_overlay<async_client_t>>(
329 async_client_t::constructor_access(),
338 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
340 return make_async_client_ws(
343 std::to_string(port),
349 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, null_strand>>>>
351 using async_client_t = async_client<ws_endpoint<as::ip::tcp::socket, null_strand>>;
352 return std::make_shared<callable_overlay<async_client_t>>(
353 async_client_t::constructor_access(),
362 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, null_strand>>>>
364 return make_async_client_no_strand_ws(
367 std::to_string(port),
375 #if defined(MQTT_USE_TLS)
377 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
379 using async_client_t = async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>;
380 return std::make_shared<callable_overlay<async_client_t>>(
381 async_client_t::constructor_access(),
385 #if defined(MQTT_USE_WS)
392 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
394 return make_tls_async_client(
397 std::to_string(port),
402 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>>>
404 using async_client_t = async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>;
405 return std::make_shared<callable_overlay<async_client_t>>(
406 async_client_t::constructor_access(),
410 #if defined(MQTT_USE_WS)
417 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>>>
419 return make_tls_async_client_no_strand(
422 std::to_string(port),
427 #if defined(MQTT_USE_WS)
429 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
431 using async_client_t = async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>;
432 return std::make_shared<callable_overlay<async_client_t>>(
433 async_client_t::constructor_access(),
442 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
444 return make_tls_async_client_ws(
447 std::to_string(port),
453 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>>>
455 using async_client_t = async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>;
456 return std::make_shared<callable_overlay<async_client_t>>(
457 async_client_t::constructor_access(),
466 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>>>
468 return make_tls_async_client_no_strand_ws(
471 std::to_string(port),
484 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
487 return std::make_shared<callable_overlay<async_client_t>>(
488 async_client_t::constructor_access(),
492 #if defined(MQTT_USE_WS)
499 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
504 std::to_string(port),
509 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
512 return std::make_shared<callable_overlay<async_client_t>>(
513 async_client_t::constructor_access(),
517 #if defined(MQTT_USE_WS)
524 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
529 std::to_string(port),
534 #if defined(MQTT_USE_WS)
536 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
538 using async_client_t = async_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>;
539 return std::make_shared<callable_overlay<async_client_t>>(
540 async_client_t::constructor_access(),
549 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
551 return make_async_client_ws_32(
554 std::to_string(port),
560 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
562 using async_client_t = async_client<ws_endpoint<as::ip::tcp::socket, null_strand>, 4>;
563 return std::make_shared<callable_overlay<async_client_t>>(
564 async_client_t::constructor_access(),
573 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
575 return make_async_client_no_strand_ws_32(
578 std::to_string(port),
586 #if defined(MQTT_USE_TLS)
588 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
590 using async_client_t = async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>;
591 return std::make_shared<callable_overlay<async_client_t>>(
592 async_client_t::constructor_access(),
596 #if defined(MQTT_USE_WS)
603 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
605 return make_tls_async_client_32(
608 std::to_string(port),
613 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>>>
615 using async_client_t = async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>;
616 return std::make_shared<callable_overlay<async_client_t>>(
617 async_client_t::constructor_access(),
621 #if defined(MQTT_USE_WS)
628 inline std::shared_ptr<callable_overlay<async_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>>>
630 return make_tls_async_client_no_strand_32(
633 std::to_string(port),
638 #if defined(MQTT_USE_WS)
640 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
642 using async_client_t = async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>;
643 return std::make_shared<callable_overlay<async_client_t>>(
644 async_client_t::constructor_access(),
653 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
655 return make_tls_async_client_ws_32(
658 std::to_string(port),
664 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>>>
666 using async_client_t = async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>;
667 return std::make_shared<callable_overlay<async_client_t>>(
668 async_client_t::constructor_access(),
677 inline std::shared_ptr<callable_overlay<async_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>>>
679 return make_tls_async_client_no_strand_ws_32(
682 std::to_string(port),
Definition: async_client.hpp:18
async_client(constructor_access, Args &&... args)
Definition: async_client.hpp:28
void unsubscribe()=delete
friend std::shared_ptr< callable_overlay< async_client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand > > > > make_async_client(as::io_context &ioc, std::string host, std::string port, protocol_version version)
Create no tls async_client with strand.
Definition: async_client.hpp:274
async_client(as::io_context &ioc, std::string host, std::string port, protocol_version version=protocol_version::v3_1_1)
Definition: async_client.hpp:251
friend std::shared_ptr< callable_overlay< async_client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand >, 4 > > > make_async_client_32(as::io_context &ioc, std::string host, std::string port, protocol_version version)
Create no tls async_client with strand.
Definition: async_client.hpp:485
friend std::shared_ptr< callable_overlay< async_client< tcp_endpoint< as::ip::tcp::socket, null_strand > > > > make_async_client_no_strand(as::io_context &ioc, std::string host, std::string port, protocol_version version)
Create no tls async_client without strand.
Definition: async_client.hpp:299
void set_auto_pub_response(bool b=true)
Set auto publish response mode.
Definition: async_client.hpp:224
friend std::shared_ptr< callable_overlay< async_client< tcp_endpoint< as::ip::tcp::socket, null_strand >, 4 > > > make_async_client_no_strand_32(as::io_context &ioc, std::string host, std::string port, protocol_version version)
Create no tls async_client without strand.
Definition: async_client.hpp:510
Definition: client.hpp:36
void set_async_pingreq(bool b)
Set pingreq message sending mode.
Definition: client.hpp:932
void set_auto_pub_response(bool b=true, bool async=true)
Set auto publish response mode.
Definition: endpoint.hpp:855
std::shared_ptr< callable_overlay< async_client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand > > > > make_async_client(as::io_context &ioc, std::string host, std::string port, protocol_version version=protocol_version::v3_1_1)
Definition: async_client.hpp:274
constexpr std::remove_reference_t< T > && force_move(T &&t)
Definition: move.hpp:20
std::shared_ptr< callable_overlay< async_client< tcp_endpoint< as::ip::tcp::socket, null_strand > > > > make_async_client_no_strand(as::io_context &ioc, std::string host, std::string port, protocol_version version=protocol_version::v3_1_1)
Definition: async_client.hpp:299
protocol_version
Definition: protocol_version.hpp:17
std::shared_ptr< callable_overlay< async_client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand >, 4 > > > make_async_client_32(as::io_context &ioc, std::string host, std::string port, protocol_version version=protocol_version::v3_1_1)
Definition: async_client.hpp:485
std::shared_ptr< callable_overlay< async_client< tcp_endpoint< as::ip::tcp::socket, null_strand >, 4 > > > make_async_client_no_strand_32(as::io_context &ioc, std::string host, std::string port, protocol_version version=protocol_version::v3_1_1)
Definition: async_client.hpp:510
Definition: client.hpp:40
Definition: null_strand.hpp:20