diff --git a/include/mqtt/async_client.hpp b/include/mqtt/async_client.hpp index c750c49db..3249fe04c 100644 --- a/include/mqtt/async_client.hpp +++ b/include/mqtt/async_client.hpp @@ -15,6 +15,468 @@ namespace MQTT_NS { template +class async_client; + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_async_client(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_async_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_async_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_async_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_async_client_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_async_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_async_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_async_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#if defined(MQTT_USE_TLS) + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_async_client(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_async_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_async_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_async_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_async_client_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_async_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_async_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_async_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#endif // defined(MQTT_USE_TLS) + + +// 32bit Packet Id (experimental) + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_async_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_async_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_async_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_async_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_async_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_async_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_async_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_async_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#if defined(MQTT_USE_TLS) + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_async_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_async_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_async_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_async_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_async_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_async_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_async_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_async_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#endif // defined(MQTT_USE_TLS) + +template class async_client : public client { using this_type = async_client; using base = client; @@ -36,6 +498,7 @@ class async_client : public client { * @param port port number * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -46,7 +509,7 @@ class async_client : public client { > > > - make_async_client(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_async_client(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create no tls async_client without strand. @@ -55,6 +518,7 @@ class async_client : public client { * @param port port number * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -65,7 +529,7 @@ class async_client : public client { > > > - make_async_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_async_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -77,6 +541,7 @@ class async_client : public client { * @return async_client object. * strand is controlled by ws_endpoint, not endpoint, so async_client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -87,7 +552,7 @@ class async_client : public client { > > > - make_async_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_async_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket async_client without strand. @@ -97,6 +562,7 @@ class async_client : public client { * @param path path string * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -107,7 +573,7 @@ class async_client : public client { > > > - make_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_async_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #if defined(MQTT_USE_TLS) @@ -118,6 +584,7 @@ class async_client : public client { * @param port port number * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -128,7 +595,7 @@ class async_client : public client { > > > - make_tls_async_client(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_async_client(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create tls async_client without strand. @@ -137,6 +604,7 @@ class async_client : public client { * @param port port number * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -147,7 +615,7 @@ class async_client : public client { > > > - make_tls_async_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_async_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -159,6 +627,7 @@ class async_client : public client { * @return async_client object. * strand is controlled by ws_endpoint, not endpoint, so async_client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -169,7 +638,7 @@ class async_client : public client { > > > - make_tls_async_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_async_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket async_client without strand. @@ -179,6 +648,7 @@ class async_client : public client { * @param path path string * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -189,7 +659,7 @@ class async_client : public client { > > > - make_tls_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_async_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #endif // defined(MQTT_USE_TLS) @@ -200,6 +670,7 @@ class async_client : public client { * @param port port number * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -211,7 +682,7 @@ class async_client : public client { > > > - make_async_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_async_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create no tls async_client without strand. @@ -220,6 +691,7 @@ class async_client : public client { * @param port port number * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -231,7 +703,7 @@ class async_client : public client { > > > - make_async_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_async_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -243,6 +715,7 @@ class async_client : public client { * @return async_client object. * strand is controlled by ws_endpoint, not endpoint, so async_client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -254,7 +727,7 @@ class async_client : public client { > > > - make_async_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_async_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket async_client without strand. @@ -264,6 +737,7 @@ class async_client : public client { * @param path path string * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -275,7 +749,7 @@ class async_client : public client { > > > - make_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_async_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #if defined(MQTT_USE_TLS) @@ -286,6 +760,7 @@ class async_client : public client { * @param port port number * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -297,7 +772,7 @@ class async_client : public client { > > > - make_tls_async_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_async_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create tls async_client without strand. @@ -306,6 +781,7 @@ class async_client : public client { * @param port port number * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -317,7 +793,7 @@ class async_client : public client { > > > - make_tls_async_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_async_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -329,6 +805,7 @@ class async_client : public client { * @return async_client object. * strand is controlled by ws_endpoint, not endpoint, so async_client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -340,7 +817,7 @@ class async_client : public client { > > > - make_tls_async_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_async_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket async_client without strand. @@ -350,6 +827,7 @@ class async_client : public client { * @param path path string * @return async_client object */ + template friend std::shared_ptr< callable_overlay< async_client< @@ -361,7 +839,7 @@ class async_client : public client { > > > - make_tls_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_async_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #endif // defined(MQTT_USE_TLS) @@ -422,17 +900,19 @@ class async_client : public client { } }; +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + strand > > > -make_async_client(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_async_client(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< tcp_endpoint< as::ip::tcp::socket, @@ -451,17 +931,19 @@ make_async_client(as::io_context& ioc, std::string host, std::string port, proto ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + strand > > > -make_async_client(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_async_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_async_client( ioc, force_move(host), @@ -470,17 +952,19 @@ make_async_client(as::io_context& ioc, std::string host, std::uint16_t port, pro ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - > + 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) { +> +make_async_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< tcp_endpoint< as::ip::tcp::socket, @@ -499,17 +983,19 @@ make_async_client_no_strand(as::io_context& ioc, std::string host, std::string p ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - > + 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::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_async_client_no_strand( ioc, force_move(host), @@ -520,17 +1006,19 @@ make_async_client_no_strand(as::io_context& ioc, std::string host, std::uint16_t #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + strand > > > -make_async_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< ws_endpoint< as::ip::tcp::socket, @@ -547,17 +1035,19 @@ make_async_client_ws(as::io_context& ioc, std::string host, std::string port, st ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + strand > > > -make_async_client_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_async_client_ws( ioc, force_move(host), @@ -567,17 +1057,19 @@ make_async_client_ws(as::io_context& ioc, std::string host, std::uint16_t port, ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - > + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand > > > -make_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< ws_endpoint< as::ip::tcp::socket, @@ -594,17 +1086,19 @@ make_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::strin ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - > + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand > > > -make_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_async_client_no_strand_ws( ioc, force_move(host), @@ -618,17 +1112,19 @@ make_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::uint1 #if defined(MQTT_USE_TLS) +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - tls::stream, - strand - > + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + strand > > > -make_tls_async_client(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< tcp_endpoint< tls::stream, @@ -647,17 +1143,19 @@ make_tls_async_client(as::io_context& ioc, std::string host, std::string port, p ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - tls::stream, - strand - > + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + strand > > > -make_tls_async_client(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_async_client( ioc, force_move(host), @@ -666,17 +1164,19 @@ make_tls_async_client(as::io_context& ioc, std::string host, std::uint16_t port, ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - tls::stream, - null_strand - > + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + null_strand > > > -make_tls_async_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< tcp_endpoint< tls::stream, @@ -695,17 +1195,19 @@ make_tls_async_client_no_strand(as::io_context& ioc, std::string host, std::stri ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - tls::stream, - null_strand - > + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + null_strand > > > -make_tls_async_client_no_strand(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_async_client_no_strand( ioc, force_move(host), @@ -716,17 +1218,19 @@ make_tls_async_client_no_strand(as::io_context& ioc, std::string host, std::uint #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - tls::stream, - strand - > + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + strand > > > -make_tls_async_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< ws_endpoint< tls::stream, @@ -743,17 +1247,19 @@ make_tls_async_client_ws(as::io_context& ioc, std::string host, std::string port ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - tls::stream, - strand - > + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + strand > > > -make_tls_async_client_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_async_client_ws( ioc, force_move(host), @@ -763,17 +1269,19 @@ make_tls_async_client_ws(as::io_context& ioc, std::string host, std::uint16_t po ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - tls::stream, - null_strand - > + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + null_strand > > > -make_tls_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< ws_endpoint< tls::stream, @@ -790,17 +1298,19 @@ make_tls_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::s ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - tls::stream, - null_strand - > + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + null_strand > > > -make_tls_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_async_client_no_strand_ws( ioc, force_move(host), @@ -817,18 +1327,20 @@ make_tls_async_client_no_strand_ws(as::io_context& ioc, std::string host, std::u // 32bit Packet Id (experimental) +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_async_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< tcp_endpoint< as::ip::tcp::socket, @@ -848,18 +1360,20 @@ make_async_client_32(as::io_context& ioc, std::string host, std::string port, pr ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + async_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_async_client_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_async_client_32( ioc, force_move(host), @@ -868,18 +1382,20 @@ make_async_client_32(as::io_context& ioc, std::string host, std::uint16_t port, ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + 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) { +> +make_async_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< tcp_endpoint< as::ip::tcp::socket, @@ -899,18 +1415,20 @@ make_async_client_no_strand_32(as::io_context& ioc, std::string host, std::strin ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + 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::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_async_client_no_strand_32( ioc, force_move(host), @@ -921,18 +1439,20 @@ make_async_client_no_strand_32(as::io_context& ioc, std::string host, std::uint1 #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_async_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< ws_endpoint< as::ip::tcp::socket, @@ -950,18 +1470,20 @@ make_async_client_ws_32(as::io_context& ioc, std::string host, std::string port, ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_async_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_async_client_ws_32( ioc, force_move(host), @@ -971,18 +1493,20 @@ make_async_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t por ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 > > -make_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< ws_endpoint< as::ip::tcp::socket, @@ -1000,18 +1524,20 @@ make_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::st ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + callable_overlay< + async_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 > > -make_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_async_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_async_client_no_strand_ws_32( ioc, force_move(host), @@ -1025,18 +1551,20 @@ make_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::ui #if defined(MQTT_USE_TLS) +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_async_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< tcp_endpoint< tls::stream, @@ -1056,18 +1584,20 @@ make_tls_async_client_32(as::io_context& ioc, std::string host, std::string port ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_async_client_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_async_client_32( ioc, force_move(host), @@ -1076,18 +1606,20 @@ make_tls_async_client_32(as::io_context& ioc, std::string host, std::uint16_t po ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_async_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< tcp_endpoint< tls::stream, @@ -1107,18 +1639,20 @@ make_tls_async_client_no_strand_32(as::io_context& ioc, std::string host, std::s ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - tcp_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + async_client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_async_client_no_strand_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_async_client_no_strand_32( ioc, force_move(host), @@ -1129,18 +1663,20 @@ make_tls_async_client_no_strand_32(as::io_context& ioc, std::string host, std::u #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_async_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< ws_endpoint< tls::stream, @@ -1158,18 +1694,20 @@ make_tls_async_client_ws_32(as::io_context& ioc, std::string host, std::string p ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_async_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_async_client_ws_32( ioc, force_move(host), @@ -1179,18 +1717,20 @@ make_tls_async_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using async_client_t = async_client< ws_endpoint< tls::stream, @@ -1208,18 +1748,20 @@ make_tls_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std ); } +template inline std::shared_ptr< - callable_overlay< - async_client< - ws_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + async_client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_async_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_async_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_async_client_no_strand_ws_32( ioc, force_move(host), diff --git a/include/mqtt/client.hpp b/include/mqtt/client.hpp index 939252801..fcba22fe4 100644 --- a/include/mqtt/client.hpp +++ b/include/mqtt/client.hpp @@ -33,6 +33,468 @@ namespace as = boost::asio; namespace mi = boost::multi_index; template +class client; + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_client(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_client_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#if defined(MQTT_USE_TLS) + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_client(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_client_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#endif // defined(MQTT_USE_TLS) + + +// 32bit Packet Id (experimental) + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#if defined(MQTT_USE_TLS) + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#endif // defined(MQTT_USE_TLS) + +template class client : public endpoint { using this_type = client; using base = endpoint; @@ -56,6 +518,7 @@ class client : public endpoint { * @param port port number * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -66,7 +529,7 @@ class client : public endpoint { > > > - make_client(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_client(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create no tls client without strand. @@ -75,6 +538,7 @@ class client : public endpoint { * @param port port number * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -85,7 +549,7 @@ class client : public endpoint { > > > - make_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -97,6 +561,7 @@ class client : public endpoint { * @return client object. * strand is controlled by ws_endpoint, not endpoint, so client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< client< @@ -107,7 +572,7 @@ class client : public endpoint { > > > - make_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket client without strand. @@ -117,6 +582,7 @@ class client : public endpoint { * @param path path string * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -127,7 +593,7 @@ class client : public endpoint { > > > - make_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #if defined(MQTT_USE_TLS) @@ -138,6 +604,7 @@ class client : public endpoint { * @param port port number * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -148,7 +615,7 @@ class client : public endpoint { > > > - make_tls_client(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_client(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create tls client without strand. @@ -157,6 +624,7 @@ class client : public endpoint { * @param port port number * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -167,7 +635,7 @@ class client : public endpoint { > > > - make_tls_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -179,6 +647,7 @@ class client : public endpoint { * @return client object. * strand is controlled by ws_endpoint, not endpoint, so client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< client< @@ -189,7 +658,7 @@ class client : public endpoint { > > > - make_tls_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket client without strand. @@ -199,6 +668,7 @@ class client : public endpoint { * @param path path string * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -209,7 +679,7 @@ class client : public endpoint { > > > - make_tls_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #endif // defined(MQTT_USE_TLS) @@ -220,6 +690,7 @@ class client : public endpoint { * @param port port number * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -231,7 +702,7 @@ class client : public endpoint { > > > - make_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create no tls client without strand. @@ -240,6 +711,7 @@ class client : public endpoint { * @param port port number * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -251,7 +723,7 @@ class client : public endpoint { > > > - make_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -263,6 +735,7 @@ class client : public endpoint { * @return client object. * strand is controlled by ws_endpoint, not endpoint, so client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< client< @@ -274,7 +747,7 @@ class client : public endpoint { > > > - make_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket client without strand. @@ -284,6 +757,7 @@ class client : public endpoint { * @param path path string * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -295,7 +769,7 @@ class client : public endpoint { > > > - make_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #if defined(MQTT_USE_TLS) @@ -306,6 +780,7 @@ class client : public endpoint { * @param port port number * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -317,7 +792,7 @@ class client : public endpoint { > > > - make_tls_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create tls client without strand. @@ -326,6 +801,7 @@ class client : public endpoint { * @param port port number * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -337,7 +813,7 @@ class client : public endpoint { > > > - make_tls_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -349,6 +825,7 @@ class client : public endpoint { * @return client object. * strand is controlled by ws_endpoint, not endpoint, so client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< client< @@ -360,7 +837,7 @@ class client : public endpoint { > > > - make_tls_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket client without strand. @@ -370,6 +847,7 @@ class client : public endpoint { * @param path path string * @return client object */ + template friend std::shared_ptr< callable_overlay< client< @@ -381,7 +859,7 @@ class client : public endpoint { > > > - make_tls_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #endif // defined(MQTT_USE_TLS) @@ -1556,17 +2034,19 @@ class client : public endpoint { #endif // defined(MQTT_USE_WS) }; +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + strand > > > -make_client(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_client(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< tcp_endpoint< as::ip::tcp::socket, @@ -1585,17 +2065,19 @@ make_client(as::io_context& ioc, std::string host, std::string port, protocol_ve ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + strand > > > -make_client(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_client( ioc, force_move(host), @@ -1604,17 +2086,19 @@ make_client(as::io_context& ioc, std::string host, std::uint16_t port, protocol_ ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - > + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand > > > -make_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< tcp_endpoint< as::ip::tcp::socket, @@ -1633,17 +2117,19 @@ make_client_no_strand(as::io_context& ioc, std::string host, std::string port, p ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - > + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand > > > -make_client_no_strand(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_client_no_strand( ioc, force_move(host), @@ -1654,17 +2140,19 @@ make_client_no_strand(as::io_context& ioc, std::string host, std::uint16_t port, #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + strand > > > -make_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< ws_endpoint< as::ip::tcp::socket, @@ -1681,17 +2169,19 @@ make_client_ws(as::io_context& ioc, std::string host, std::string port, std::str ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + strand > > > -make_client_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_client_ws( ioc, force_move(host), @@ -1701,17 +2191,19 @@ make_client_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::s ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - > + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + null_strand > > > -make_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< ws_endpoint< as::ip::tcp::socket, @@ -1728,17 +2220,19 @@ make_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - > + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + null_strand > > > -make_client_no_strand_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_client_no_strand_ws( ioc, force_move(host), @@ -1752,17 +2246,19 @@ make_client_no_strand_ws(as::io_context& ioc, std::string host, std::uint16_t po #if defined(MQTT_USE_TLS) +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - tls::stream, - strand - > + callable_overlay< + client< + tcp_endpoint< + tls::stream, + strand > > > -make_tls_client(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< tcp_endpoint< tls::stream, @@ -1781,17 +2277,19 @@ make_tls_client(as::io_context& ioc, std::string host, std::string port, protoco ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - tls::stream, - strand - > + callable_overlay< + client< + tcp_endpoint< + tls::stream, + strand > > > -make_tls_client(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_client( ioc, force_move(host), @@ -1800,17 +2298,19 @@ make_tls_client(as::io_context& ioc, std::string host, std::uint16_t port, proto ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - tls::stream, - null_strand - > + callable_overlay< + client< + tcp_endpoint< + tls::stream, + null_strand > > > -make_tls_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< tcp_endpoint< tls::stream, @@ -1829,17 +2329,19 @@ make_tls_client_no_strand(as::io_context& ioc, std::string host, std::string por ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - tls::stream, - null_strand - > + callable_overlay< + client< + tcp_endpoint< + tls::stream, + null_strand > > > -make_tls_client_no_strand(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_client_no_strand( ioc, force_move(host), @@ -1850,17 +2352,19 @@ make_tls_client_no_strand(as::io_context& ioc, std::string host, std::uint16_t p #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - tls::stream, - strand - > + callable_overlay< + client< + ws_endpoint< + tls::stream, + strand > > > -make_tls_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< ws_endpoint< tls::stream, @@ -1877,17 +2381,19 @@ make_tls_client_ws(as::io_context& ioc, std::string host, std::string port, std: ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - tls::stream, - strand - > + callable_overlay< + client< + ws_endpoint< + tls::stream, + strand > > > -make_tls_client_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_client_ws( ioc, force_move(host), @@ -1897,17 +2403,19 @@ make_tls_client_ws(as::io_context& ioc, std::string host, std::uint16_t port, st ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - tls::stream, - null_strand - > + callable_overlay< + client< + ws_endpoint< + tls::stream, + null_strand > > > -make_tls_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< ws_endpoint< tls::stream, @@ -1924,17 +2432,19 @@ make_tls_client_no_strand_ws(as::io_context& ioc, std::string host, std::string ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - tls::stream, - null_strand - > + callable_overlay< + client< + ws_endpoint< + tls::stream, + null_strand > > > -make_tls_client_no_strand_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_client_no_strand_ws( ioc, force_move(host), @@ -1951,18 +2461,20 @@ make_tls_client_no_strand_ws(as::io_context& ioc, std::string host, std::uint16_ // 32bit Packet Id (experimental) +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< tcp_endpoint< as::ip::tcp::socket, @@ -1982,18 +2494,20 @@ make_client_32(as::io_context& ioc, std::string host, std::string port, protocol ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_client_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_client_32( ioc, force_move(host), @@ -2002,18 +2516,20 @@ make_client_32(as::io_context& ioc, std::string host, std::uint16_t port, protoc ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 > > -make_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< tcp_endpoint< as::ip::tcp::socket, @@ -2033,18 +2549,20 @@ make_client_no_strand_32(as::io_context& ioc, std::string host, std::string port ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + callable_overlay< + client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 > > -make_client_no_strand_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_client_no_strand_32( ioc, force_move(host), @@ -2055,18 +2573,20 @@ make_client_no_strand_32(as::io_context& ioc, std::string host, std::uint16_t po #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< ws_endpoint< as::ip::tcp::socket, @@ -2084,18 +2604,20 @@ make_client_ws_32(as::io_context& ioc, std::string host, std::string port, std:: ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_client_ws_32( ioc, force_move(host), @@ -2105,18 +2627,20 @@ make_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 > > -make_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< ws_endpoint< as::ip::tcp::socket, @@ -2134,18 +2658,20 @@ make_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string p ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + callable_overlay< + client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 > > -make_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_client_no_strand_ws_32( ioc, force_move(host), @@ -2159,18 +2685,20 @@ make_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::uint16_t #if defined(MQTT_USE_TLS) +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + client< + tcp_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< tcp_endpoint< tls::stream, @@ -2190,18 +2718,20 @@ make_tls_client_32(as::io_context& ioc, std::string host, std::string port, prot ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + client< + tcp_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_client_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_client_32( ioc, force_move(host), @@ -2210,18 +2740,20 @@ make_tls_client_32(as::io_context& ioc, std::string host, std::uint16_t port, pr ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< tcp_endpoint< tls::stream, @@ -2241,18 +2773,20 @@ make_tls_client_no_strand_32(as::io_context& ioc, std::string host, std::string ); } +template inline std::shared_ptr< - callable_overlay< - client< - tcp_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_client_no_strand_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_client_no_strand_32( ioc, force_move(host), @@ -2263,18 +2797,20 @@ make_tls_client_no_strand_32(as::io_context& ioc, std::string host, std::uint16_ #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + client< + ws_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< ws_endpoint< tls::stream, @@ -2292,18 +2828,20 @@ make_tls_client_ws_32(as::io_context& ioc, std::string host, std::string port, s ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + client< + ws_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_client_ws_32( ioc, force_move(host), @@ -2313,18 +2851,20 @@ make_tls_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using client_t = client< ws_endpoint< tls::stream, @@ -2342,18 +2882,20 @@ make_tls_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::stri ); } +template inline std::shared_ptr< - callable_overlay< - client< - ws_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_client_no_strand_ws_32( ioc, force_move(host), diff --git a/include/mqtt/property_variant.hpp b/include/mqtt/property_variant.hpp index ecebbf4da..23f2fb055 100644 --- a/include/mqtt/property_variant.hpp +++ b/include/mqtt/property_variant.hpp @@ -141,8 +141,13 @@ struct less_than_visitor { } }; +template inline -bool operator<(property_variant const& lhs, property_variant const& rhs) { +std::enable_if_t< + std::is_same::value, + bool +> +operator<(PropertyVariant const& lhs, PropertyVariant const& rhs) { return MQTT_NS::visit( less_than_visitor(), lhs, @@ -161,8 +166,13 @@ struct equal_visitor { } }; +template inline -bool operator==(property_variant const& lhs, property_variant const& rhs) { +std::enable_if_t< + std::is_same::value, + bool +> +operator==(PropertyVariant const& lhs, PropertyVariant const& rhs) { return MQTT_NS::visit( equal_visitor(), lhs, @@ -170,8 +180,13 @@ bool operator==(property_variant const& lhs, property_variant const& rhs) { ); } +template inline -bool operator!=(property_variant const& lhs, property_variant const& rhs) { +std::enable_if_t< + std::is_same::value, + bool +> +operator!=(PropertyVariant const& lhs, PropertyVariant const& rhs) { return !MQTT_NS::visit( equal_visitor(), lhs, diff --git a/include/mqtt/sync_client.hpp b/include/mqtt/sync_client.hpp index fe7768116..1124ac47b 100644 --- a/include/mqtt/sync_client.hpp +++ b/include/mqtt/sync_client.hpp @@ -15,6 +15,469 @@ namespace MQTT_NS { template +class sync_client; + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_sync_client(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_sync_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_sync_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_sync_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_sync_client_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + strand + > + > + > +> +make_sync_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_sync_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + > + > + > +> +make_sync_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#if defined(MQTT_USE_TLS) + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_sync_client(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_sync_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_sync_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_sync_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_sync_client_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + strand + > + > + > +> +make_tls_sync_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_sync_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + null_strand + > + > + > +> +make_tls_sync_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#endif // defined(MQTT_USE_TLS) + + +// 32bit Packet Id (experimental) + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_sync_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_sync_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_sync_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_sync_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_sync_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 + > + > +> +make_sync_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_sync_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 + > + > +> +make_sync_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#if defined(MQTT_USE_TLS) + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_sync_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_sync_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_sync_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_sync_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1); + +#if defined(MQTT_USE_WS) + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_sync_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + strand + >, + 4 + > + > +> +make_tls_sync_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_sync_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +template +std::shared_ptr< + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 + > + > +> +make_tls_sync_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1); + +#endif // defined(MQTT_USE_WS) + +#endif // defined(MQTT_USE_TLS) + + +template class sync_client : public client { using this_type = sync_client; using base = client; @@ -36,6 +499,7 @@ class sync_client : public client { * @param port port number * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -46,7 +510,7 @@ class sync_client : public client { > > > - make_sync_client(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_sync_client(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create no tls sync_client without strand. @@ -55,6 +519,7 @@ class sync_client : public client { * @param port port number * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -65,7 +530,7 @@ class sync_client : public client { > > > - make_sync_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_sync_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -77,6 +542,7 @@ class sync_client : public client { * @return sync_client object. * strand is controlled by ws_endpoint, not endpoint, so sync_client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -87,7 +553,7 @@ class sync_client : public client { > > > - make_sync_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_sync_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket sync_client without strand. @@ -97,6 +563,7 @@ class sync_client : public client { * @param path path string * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -107,7 +574,7 @@ class sync_client : public client { > > > - make_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_sync_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #if defined(MQTT_USE_TLS) @@ -118,6 +585,7 @@ class sync_client : public client { * @param port port number * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -128,7 +596,7 @@ class sync_client : public client { > > > - make_tls_sync_client(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_sync_client(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create tls sync_client without strand. @@ -137,6 +605,7 @@ class sync_client : public client { * @param port port number * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -147,7 +616,7 @@ class sync_client : public client { > > > - make_tls_sync_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_sync_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -159,6 +628,7 @@ class sync_client : public client { * @return sync_client object. * strand is controlled by ws_endpoint, not endpoint, so sync_client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -169,7 +639,7 @@ class sync_client : public client { > > > - make_tls_sync_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_sync_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket sync_client without strand. @@ -179,6 +649,7 @@ class sync_client : public client { * @param path path string * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -189,7 +660,7 @@ class sync_client : public client { > > > - make_tls_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_sync_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #endif // defined(MQTT_USE_TLS) @@ -200,6 +671,7 @@ class sync_client : public client { * @param port port number * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -211,7 +683,7 @@ class sync_client : public client { > > > - make_sync_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_sync_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create no tls sync_client without strand. @@ -220,6 +692,7 @@ class sync_client : public client { * @param port port number * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -231,7 +704,7 @@ class sync_client : public client { > > > - make_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_sync_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -243,6 +716,7 @@ class sync_client : public client { * @return sync_client object. * strand is controlled by ws_endpoint, not endpoint, so sync_client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -254,7 +728,7 @@ class sync_client : public client { > > > - make_sync_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_sync_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket sync_client without strand. @@ -264,6 +738,7 @@ class sync_client : public client { * @param path path string * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -275,7 +750,7 @@ class sync_client : public client { > > > - make_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_sync_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #if defined(MQTT_USE_TLS) @@ -286,6 +761,7 @@ class sync_client : public client { * @param port port number * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -297,7 +773,7 @@ class sync_client : public client { > > > - make_tls_sync_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_sync_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version); /** * @brief Create tls sync_client without strand. @@ -306,6 +782,7 @@ class sync_client : public client { * @param port port number * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -317,7 +794,7 @@ class sync_client : public client { > > > - make_tls_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version); + make_tls_sync_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version); #if defined(MQTT_USE_WS) /** @@ -329,6 +806,7 @@ class sync_client : public client { * @return sync_client object. * strand is controlled by ws_endpoint, not endpoint, so sync_client has null_strand template argument. */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -340,7 +818,7 @@ class sync_client : public client { > > > - make_tls_sync_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_sync_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); /** * @brief Create no tls websocket sync_client without strand. @@ -350,6 +828,7 @@ class sync_client : public client { * @param path path string * @return sync_client object */ + template friend std::shared_ptr< callable_overlay< sync_client< @@ -361,7 +840,7 @@ class sync_client : public client { > > > - make_tls_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version); + make_tls_sync_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version); #endif // defined(MQTT_USE_WS) #endif // defined(MQTT_USE_TLS) @@ -421,17 +900,19 @@ class sync_client : public client { } }; +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + strand > > > -make_sync_client(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< tcp_endpoint< as::ip::tcp::socket, @@ -450,17 +931,19 @@ make_sync_client(as::io_context& ioc, std::string host, std::string port, protoc ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + strand > > > -make_sync_client(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_sync_client( ioc, force_move(host), @@ -469,17 +952,19 @@ make_sync_client(as::io_context& ioc, std::string host, std::uint16_t port, prot ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - > + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand > > > -make_sync_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< tcp_endpoint< as::ip::tcp::socket, @@ -497,17 +982,19 @@ make_sync_client_no_strand(as::io_context& ioc, std::string host, std::string po ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - > + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand > > > -make_sync_client_no_strand(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_sync_client_no_strand( ioc, force_move(host), @@ -518,17 +1005,19 @@ make_sync_client_no_strand(as::io_context& ioc, std::string host, std::uint16_t #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + strand > > > -make_sync_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< ws_endpoint< as::ip::tcp::socket, @@ -545,17 +1034,19 @@ make_sync_client_ws(as::io_context& ioc, std::string host, std::string port, std ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - as::ip::tcp::socket, - strand - > + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + strand > > > -make_sync_client_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_sync_client_ws( ioc, force_move(host), @@ -565,17 +1056,19 @@ make_sync_client_ws(as::io_context& ioc, std::string host, std::uint16_t port, s ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - > + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand > > > -make_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< ws_endpoint< as::ip::tcp::socket, @@ -592,17 +1085,19 @@ make_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::string ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - > + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand > > > -make_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_sync_client_no_strand_ws( ioc, force_move(host), @@ -616,17 +1111,19 @@ make_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::uint16 #if defined(MQTT_USE_TLS) +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - tls::stream, - strand - > + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + strand > > > -make_tls_sync_client(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< tcp_endpoint< tls::stream, @@ -645,17 +1142,19 @@ make_tls_sync_client(as::io_context& ioc, std::string host, std::string port, pr ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - tls::stream, - strand - > + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + strand > > > -make_tls_sync_client(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_sync_client( ioc, force_move(host), @@ -664,17 +1163,19 @@ make_tls_sync_client(as::io_context& ioc, std::string host, std::uint16_t port, ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - tls::stream, - null_strand - > + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + null_strand > > > -make_tls_sync_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_no_strand(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< tcp_endpoint< tls::stream, @@ -693,17 +1194,19 @@ make_tls_sync_client_no_strand(as::io_context& ioc, std::string host, std::strin ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - tls::stream, - null_strand - > + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + null_strand > > > -make_tls_sync_client_no_strand(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_no_strand(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_sync_client_no_strand( ioc, force_move(host), @@ -714,17 +1217,19 @@ make_tls_sync_client_no_strand(as::io_context& ioc, std::string host, std::uint1 #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - tls::stream, - strand - > + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + strand > > > -make_tls_sync_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< ws_endpoint< tls::stream, @@ -741,17 +1246,19 @@ make_tls_sync_client_ws(as::io_context& ioc, std::string host, std::string port, ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - tls::stream, - strand - > + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + strand > > > -make_tls_sync_client_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_sync_client_ws( ioc, force_move(host), @@ -761,17 +1268,19 @@ make_tls_sync_client_ws(as::io_context& ioc, std::string host, std::uint16_t por ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - tls::stream, - null_strand - > + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + null_strand > > > -make_tls_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_no_strand_ws(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< ws_endpoint< tls::stream, @@ -788,17 +1297,19 @@ make_tls_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::st ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - tls::stream, - null_strand - > + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + null_strand > > > -make_tls_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_no_strand_ws(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_sync_client_no_strand_ws( ioc, force_move(host), @@ -815,18 +1326,20 @@ make_tls_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::ui // 32bit Packet Id (experimental) +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_sync_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< tcp_endpoint< as::ip::tcp::socket, @@ -846,18 +1359,20 @@ make_sync_client_32(as::io_context& ioc, std::string host, std::string port, pro ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_sync_client_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_sync_client_32( ioc, force_move(host), @@ -866,18 +1381,20 @@ make_sync_client_32(as::io_context& ioc, std::string host, std::uint16_t port, p ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 > > -make_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< tcp_endpoint< as::ip::tcp::socket, @@ -897,18 +1414,20 @@ make_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::string ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + callable_overlay< + sync_client< + tcp_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 > > -make_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_sync_client_no_strand_32( ioc, force_move(host), @@ -919,18 +1438,20 @@ make_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::uint16 #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_sync_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< ws_endpoint< as::ip::tcp::socket, @@ -948,18 +1469,20 @@ make_sync_client_ws_32(as::io_context& ioc, std::string host, std::string port, ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - as::ip::tcp::socket, - strand - >, - 4 - > + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + strand + >, + 4 > > -make_sync_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_sync_client_ws_32( ioc, force_move(host), @@ -969,18 +1492,20 @@ make_sync_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t port ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 > > -make_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< ws_endpoint< as::ip::tcp::socket, @@ -998,18 +1523,20 @@ make_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::str ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - as::ip::tcp::socket, - null_strand - >, - 4 - > + callable_overlay< + sync_client< + ws_endpoint< + as::ip::tcp::socket, + null_strand + >, + 4 > > -make_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_sync_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_sync_client_no_strand_ws_32( ioc, force_move(host), @@ -1023,18 +1550,20 @@ make_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::uin #if defined(MQTT_USE_TLS) +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_sync_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< tcp_endpoint< tls::stream, @@ -1054,18 +1583,20 @@ make_tls_sync_client_32(as::io_context& ioc, std::string host, std::string port, ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_sync_client_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_sync_client_32( ioc, force_move(host), @@ -1074,18 +1605,20 @@ make_tls_sync_client_32(as::io_context& ioc, std::string host, std::uint16_t por ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_no_strand_32(Ioc& ioc, std::string host, std::string port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< tcp_endpoint< tls::stream, @@ -1105,18 +1638,20 @@ make_tls_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::st ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - tcp_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + sync_client< + tcp_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_no_strand_32(Ioc& ioc, std::string host, std::uint16_t port, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_sync_client_no_strand_32( ioc, force_move(host), @@ -1127,18 +1662,20 @@ make_tls_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::ui #if defined(MQTT_USE_WS) +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_sync_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< ws_endpoint< tls::stream, @@ -1156,18 +1693,20 @@ make_tls_sync_client_ws_32(as::io_context& ioc, std::string host, std::string po ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - tls::stream, - strand - >, - 4 - > + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + strand + >, + 4 > > -make_tls_sync_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_sync_client_ws_32( ioc, force_move(host), @@ -1177,18 +1716,20 @@ make_tls_sync_client_ws_32(as::io_context& ioc, std::string host, std::uint16_t ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_no_strand_ws_32(Ioc& ioc, std::string host, std::string port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); using sync_client_t = sync_client< ws_endpoint< tls::stream, @@ -1206,18 +1747,20 @@ make_tls_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std: ); } +template inline std::shared_ptr< - callable_overlay< - sync_client< - ws_endpoint< - tls::stream, - null_strand - >, - 4 - > + callable_overlay< + sync_client< + ws_endpoint< + tls::stream, + null_strand + >, + 4 > > -make_tls_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::uint16_t port, std::string path = "/", protocol_version version = protocol_version::v3_1_1) { +> +make_tls_sync_client_no_strand_ws_32(Ioc& ioc, std::string host, std::uint16_t port, std::string path, protocol_version version) { + static_assert(std::is_same::value, "The type of ioc must be boost::asio::io_context"); return make_tls_sync_client_no_strand_ws_32( ioc, force_move(host),