mqtt_cpp
sync_client.hpp
Go to the documentation of this file.
1 // Copyright Takatoshi Kondo 2019
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 #if !defined(MQTT_SYNC_CLIENT_HPP)
8 #define MQTT_SYNC_CLIENT_HPP
9 
10 #include <mqtt/namespace.hpp>
11 #include <mqtt/client.hpp>
12 #include <mqtt/move.hpp>
14 
15 namespace MQTT_NS {
16 
17 template <typename Socket, std::size_t PacketIdBytes = 2>
18 class sync_client : public client<Socket, PacketIdBytes> {
21  using constructor_access = typename base::constructor_access;
22 public:
23 
27  template<typename ... Args>
28  sync_client(constructor_access, Args && ... args)
29  : sync_client(std::forward<Args>(args)...)
30  { }
31 
39  friend std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
40  make_sync_client(as::io_context& ioc, std::string host, std::string port, protocol_version version);
41 
49  friend std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, null_strand>>>>
50  make_sync_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version);
51 
52 #if defined(MQTT_USE_WS)
62  friend std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
63  make_sync_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version);
64 
73  friend std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, null_strand>>>>
74  make_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version);
75 #endif // defined(MQTT_USE_WS)
76 
77 #if defined(MQTT_USE_TLS)
85  friend std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
86  make_tls_sync_client(as::io_context& ioc, std::string host, std::string port, protocol_version version);
87 
95  friend std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>>>
96  make_tls_sync_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version);
97 
98 #if defined(MQTT_USE_WS)
108  friend std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
109  make_tls_sync_client_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version);
110 
119  friend std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>>>
120  make_tls_sync_client_no_strand_ws(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version);
121 #endif // defined(MQTT_USE_WS)
122 #endif // defined(MQTT_USE_TLS)
123 
131  friend std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
132  make_sync_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version);
133 
141  friend std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
142  make_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version);
143 
144 #if defined(MQTT_USE_WS)
154  friend std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
155  make_sync_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version);
156 
165  friend std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
166  make_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version);
167 #endif // defined(MQTT_USE_WS)
168 
169 #if defined(MQTT_USE_TLS)
177  friend std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
178  make_tls_sync_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version);
179 
187  friend std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>>>
188  make_tls_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version);
189 
190 #if defined(MQTT_USE_WS)
200  friend std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
201  make_tls_sync_client_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version);
202 
211  friend std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>>>
212  make_tls_sync_client_no_strand_ws_32(as::io_context& ioc, std::string host, std::string port, std::string path, protocol_version version);
213 #endif // defined(MQTT_USE_WS)
214 #endif // defined(MQTT_USE_TLS)
215 
223  void set_auto_pub_response(bool b = true) {
224  base::set_auto_pub_response(b, false);
225  }
226 
227  void async_connect() = delete;
228  void async_disconnect() = delete;
229 
230  void async_publish() = delete;
231  void async_subscribe() = delete;
232  void async_unsubscribe() = delete;
233  void async_pingresp() = delete;
234  void async_connack() = delete;
235  void async_puback() = delete;
236  void async_pubrec() = delete;
237  void async_pubrel() = delete;
238  void async_pubcomp() = delete;
239  void async_suback() = delete;
240  void async_unsuback() = delete;
241 
242 protected:
243  // Ensure that only code that knows the *exact* type of an object
244  // inheriting from this abstract base class can destruct it.
245  // This avoids issues of the destructor not triggering destruction
246  // of derived classes, and any member variables contained in them.
247  // Note: Not virtual to avoid need for a vtable when possible.
248  ~sync_client() = default;
249 
251  as::io_context& ioc,
252  std::string host,
253  std::string port
254 #if defined(MQTT_USE_WS)
255  ,
256  std::string path = "/"
257 #endif // defined(MQTT_USE_WS)
258  ,
260  ):base(ioc, force_move(host), force_move(port)
261 #if defined(MQTT_USE_WS)
262  , force_move(path)
263 #endif // defined(MQTT_USE_WS)
264  ,
265  version
266  ) {
268  }
269 };
270 
271 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
272 make_sync_client(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) {
274  return std::make_shared<callable_overlay<sync_client_t>>(
275  sync_client_t::constructor_access(),
276  ioc,
277  force_move(host),
278  force_move(port),
279 #if defined(MQTT_USE_WS)
280  "/",
281 #endif // defined(MQTT_USE_WS)
282  version
283  );
284 }
285 
286 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
287 make_sync_client(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) {
288  return make_sync_client(
289  ioc,
290  force_move(host),
291  std::to_string(port),
292  version
293  );
294 }
295 
296 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, null_strand>>>>
297 make_sync_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) {
299  return std::make_shared<callable_overlay<sync_client_t>>(
300  sync_client_t::constructor_access(),
301  ioc,
302  force_move(host),
303  force_move(port),
304 #if defined(MQTT_USE_WS)
305  "/",
306 #endif // defined(MQTT_USE_WS)
307  version
308  );
309 }
310 
311 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, null_strand>>>>
312 make_sync_client_no_strand(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) {
314  ioc,
315  force_move(host),
316  std::to_string(port),
317  version
318  );
319 }
320 
321 #if defined(MQTT_USE_WS)
322 
323 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
324 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) {
325  using sync_client_t = sync_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>>;
326  return std::make_shared<callable_overlay<sync_client_t>>(
327  sync_client_t::constructor_access(),
328  ioc,
329  force_move(host),
330  force_move(port),
331  force_move(path),
332  version
333  );
334 }
335 
336 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>>>>
337 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) {
338  return make_sync_client_ws(
339  ioc,
340  force_move(host),
341  std::to_string(port),
342  force_move(path),
343  version
344  );
345 }
346 
347 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, null_strand>>>>
348 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) {
349  using sync_client_t = sync_client<ws_endpoint<as::ip::tcp::socket, null_strand>>;
350  return std::make_shared<callable_overlay<sync_client_t>>(
351  sync_client_t::constructor_access(),
352  ioc,
353  force_move(host),
354  force_move(port),
355  force_move(path),
356  version
357  );
358 }
359 
360 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, null_strand>>>>
361 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) {
362  return make_sync_client_no_strand_ws(
363  ioc,
364  force_move(host),
365  std::to_string(port),
366  force_move(path),
367  version
368  );
369 }
370 
371 #endif // defined(MQTT_USE_WS)
372 
373 #if defined(MQTT_USE_TLS)
374 
375 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
376 make_tls_sync_client(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) {
377  using sync_client_t = sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>;
378  return std::make_shared<callable_overlay<sync_client_t>>(
379  sync_client_t::constructor_access(),
380  ioc,
381  force_move(host),
382  force_move(port),
383 #if defined(MQTT_USE_WS)
384  "/",
385 #endif // defined(MQTT_USE_WS)
386  version
387  );
388 }
389 
390 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
391 make_tls_sync_client(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) {
392  return make_tls_sync_client(
393  ioc,
394  force_move(host),
395  std::to_string(port),
396  version
397  );
398 }
399 
400 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>>>
401 make_tls_sync_client_no_strand(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) {
402  using sync_client_t = sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>;
403  return std::make_shared<callable_overlay<sync_client_t>>(
404  sync_client_t::constructor_access(),
405  ioc,
406  force_move(host),
407  force_move(port),
408 #if defined(MQTT_USE_WS)
409  "/",
410 #endif // defined(MQTT_USE_WS)
411  version
412  );
413 }
414 
415 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>>>
416 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) {
417  return make_tls_sync_client_no_strand(
418  ioc,
419  force_move(host),
420  std::to_string(port),
421  version
422  );
423 }
424 
425 #if defined(MQTT_USE_WS)
426 
427 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
428 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) {
429  using sync_client_t = sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>;
430  return std::make_shared<callable_overlay<sync_client_t>>(
431  sync_client_t::constructor_access(),
432  ioc,
433  force_move(host),
434  force_move(port),
435  force_move(path),
436  version
437  );
438 }
439 
440 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>>>>
441 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) {
442  return make_tls_sync_client_ws(
443  ioc,
444  force_move(host),
445  std::to_string(port),
446  force_move(path),
447  version
448  );
449 }
450 
451 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>>>
452 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) {
453  using sync_client_t = sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>;
454  return std::make_shared<callable_overlay<sync_client_t>>(
455  sync_client_t::constructor_access(),
456  ioc,
457  force_move(host),
458  force_move(port),
459  force_move(path),
460  version
461  );
462 }
463 
464 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>>>>
465 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) {
466  return make_tls_sync_client_no_strand_ws(
467  ioc,
468  force_move(host),
469  std::to_string(port),
470  force_move(path),
471  version
472  );
473 }
474 
475 #endif // defined(MQTT_USE_WS)
476 
477 #endif // defined(MQTT_USE_TLS)
478 
479 
480 // 32bit Packet Id (experimental)
481 
482 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
483 make_sync_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) {
485  return std::make_shared<callable_overlay<sync_client_t>>(
486  sync_client_t::constructor_access(),
487  ioc,
488  force_move(host),
489  force_move(port),
490 #if defined(MQTT_USE_WS)
491  "/",
492 #endif // defined(MQTT_USE_WS)
493  version
494  );
495 }
496 
497 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
498 make_sync_client_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) {
499  return make_sync_client_32(
500  ioc,
501  force_move(host),
502  std::to_string(port),
503  version
504  );
505 }
506 
507 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
508 make_sync_client_no_strand_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) {
510  return std::make_shared<callable_overlay<sync_client_t>>(
511  sync_client_t::constructor_access(),
512  ioc,
513  force_move(host),
514  force_move(port),
515 #if defined(MQTT_USE_WS)
516  "/",
517 #endif // defined(MQTT_USE_WS)
518  version
519  );
520 }
521 
522 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
523 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) {
525  ioc,
526  force_move(host),
527  std::to_string(port),
528  version
529  );
530 }
531 
532 #if defined(MQTT_USE_WS)
533 
534 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
535 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) {
536  using sync_client_t = sync_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>;
537  return std::make_shared<callable_overlay<sync_client_t>>(
538  sync_client_t::constructor_access(),
539  ioc,
540  force_move(host),
541  force_move(port),
542  force_move(path),
543  version
544  );
545 }
546 
547 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, as::io_context::strand>, 4>>>
548 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) {
549  return make_sync_client_ws_32(
550  ioc,
551  force_move(host),
552  std::to_string(port),
553  force_move(path),
554  version
555  );
556 }
557 
558 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
559 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) {
560  using sync_client_t = sync_client<ws_endpoint<as::ip::tcp::socket, null_strand>, 4>;
561  return std::make_shared<callable_overlay<sync_client_t>>(
562  sync_client_t::constructor_access(),
563  ioc,
564  force_move(host),
565  force_move(port),
566  force_move(path),
567  version
568  );
569 }
570 
571 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<as::ip::tcp::socket, null_strand>, 4>>>
572 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) {
573  return make_sync_client_no_strand_ws_32(
574  ioc,
575  force_move(host),
576  std::to_string(port),
577  force_move(path),
578  version
579  );
580 }
581 
582 #endif // defined(MQTT_USE_WS)
583 
584 #if defined(MQTT_USE_TLS)
585 
586 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
587 make_tls_sync_client_32(as::io_context& ioc, std::string host, std::string port, protocol_version version = protocol_version::v3_1_1) {
588  using sync_client_t = sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>;
589  return std::make_shared<callable_overlay<sync_client_t>>(
590  sync_client_t::constructor_access(),
591  ioc,
592  force_move(host),
593  force_move(port),
594 #if defined(MQTT_USE_WS)
595  "/",
596 #endif // defined(MQTT_USE_WS)
597  version
598  );
599 }
600 
601 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
602 make_tls_sync_client_32(as::io_context& ioc, std::string host, std::uint16_t port, protocol_version version = protocol_version::v3_1_1) {
603  return make_tls_sync_client_32(
604  ioc,
605  force_move(host),
606  std::to_string(port),
607  version
608  );
609 }
610 
611 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>>>
612 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) {
613  using sync_client_t = sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>;
614  return std::make_shared<callable_overlay<sync_client_t>>(
615  sync_client_t::constructor_access(),
616  ioc,
617  force_move(host),
618  force_move(port),
619 #if defined(MQTT_USE_WS)
620  "/",
621 #endif // defined(MQTT_USE_WS)
622  version
623  );
624 }
625 
626 inline std::shared_ptr<callable_overlay<sync_client<tcp_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>>>
627 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) {
628  return make_tls_sync_client_no_strand_32(
629  ioc,
630  force_move(host),
631  std::to_string(port),
632  version
633  );
634 }
635 
636 #if defined(MQTT_USE_WS)
637 
638 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
639 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) {
640  using sync_client_t = sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>;
641  return std::make_shared<callable_overlay<sync_client_t>>(
642  sync_client_t::constructor_access(),
643  ioc,
644  force_move(host),
645  force_move(port),
646  force_move(path),
647  version
648  );
649 }
650 
651 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, as::io_context::strand>, 4>>>
652 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) {
653  return make_tls_sync_client_ws_32(
654  ioc,
655  force_move(host),
656  std::to_string(port),
657  force_move(path),
658  version
659  );
660 }
661 
662 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>>>
663 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) {
664  using sync_client_t = sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>;
665  return std::make_shared<callable_overlay<sync_client_t>>(
666  sync_client_t::constructor_access(),
667  ioc,
668  force_move(host),
669  force_move(port),
670  force_move(path),
671  version
672  );
673 }
674 
675 inline std::shared_ptr<callable_overlay<sync_client<ws_endpoint<tls::stream<as::ip::tcp::socket>, null_strand>, 4>>>
676 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) {
677  return make_tls_sync_client_no_strand_ws_32(
678  ioc,
679  force_move(host),
680  std::to_string(port),
681  force_move(path),
682  version
683  );
684 }
685 
686 #endif // defined(MQTT_USE_WS)
687 
688 #endif // defined(MQTT_USE_TLS)
689 
690 } // namespace MQTT_NS
691 
692 #endif // MQTT_SYNC_CLIENT_HPP
Definition: client.hpp:36
void set_auto_pub_response(bool b=true, bool async=true)
Set auto publish response mode.
Definition: endpoint.hpp:855
Definition: sync_client.hpp:18
void async_pubrec()=delete
friend std::shared_ptr< 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)
Create no tls sync_client without strand.
Definition: sync_client.hpp:508
void async_connect()=delete
void async_connack()=delete
void async_pubcomp()=delete
void async_disconnect()=delete
friend std::shared_ptr< callable_overlay< sync_client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand > > > > make_sync_client(as::io_context &ioc, std::string host, std::string port, protocol_version version)
Create no tls sync_client with strand.
Definition: sync_client.hpp:272
sync_client(as::io_context &ioc, std::string host, std::string port, protocol_version version=protocol_version::v3_1_1)
Definition: sync_client.hpp:250
void async_puback()=delete
void async_publish()=delete
void set_auto_pub_response(bool b=true)
Set auto publish response mode.
Definition: sync_client.hpp:223
friend std::shared_ptr< callable_overlay< sync_client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand >, 4 > > > make_sync_client_32(as::io_context &ioc, std::string host, std::string port, protocol_version version)
Create no tls sync_client with strand.
Definition: sync_client.hpp:483
void async_unsuback()=delete
sync_client(constructor_access, Args &&... args)
Definition: sync_client.hpp:28
void async_subscribe()=delete
void async_pubrel()=delete
void async_unsubscribe()=delete
friend std::shared_ptr< 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)
Create no tls sync_client without strand.
Definition: sync_client.hpp:297
void async_suback()=delete
void async_pingresp()=delete
Definition: any.hpp:27
constexpr std::remove_reference_t< T > && force_move(T &&t)
Definition: move.hpp:20
protocol_version
Definition: protocol_version.hpp:17
std::shared_ptr< 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)
Definition: sync_client.hpp:297
std::shared_ptr< callable_overlay< sync_client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand > > > > make_sync_client(as::io_context &ioc, std::string host, std::string port, protocol_version version=protocol_version::v3_1_1)
Definition: sync_client.hpp:272
std::shared_ptr< callable_overlay< sync_client< tcp_endpoint< as::ip::tcp::socket, as::io_context::strand >, 4 > > > make_sync_client_32(as::io_context &ioc, std::string host, std::string port, protocol_version version=protocol_version::v3_1_1)
Definition: sync_client.hpp:483
std::shared_ptr< 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)
Definition: sync_client.hpp:508
Definition: client.hpp:40
Definition: null_strand.hpp:20