subscribe_entry.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright Takatoshi Kondo 2020
  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. #if !defined(MQTT_SUBSCRIBE_ENTRY_HPP)
  7. #define MQTT_SUBSCRIBE_ENTRY_HPP
  8. #include <mqtt/config.hpp>
  9. #include <mqtt/namespace.hpp>
  10. #include <mqtt/buffer.hpp>
  11. #include <mqtt/subscribe_options.hpp>
  12. namespace MQTT_NS {
  13. struct subscribe_entry {
  14. subscribe_entry(
  15. buffer share_name,
  16. buffer topic_filter,
  17. subscribe_options subopts)
  18. : share_name { force_move(share_name) },
  19. topic_filter { force_move(topic_filter) },
  20. subopts { subopts }
  21. {}
  22. subscribe_entry(
  23. buffer topic_filter,
  24. subscribe_options subopts)
  25. : topic_filter { force_move(topic_filter) },
  26. subopts { subopts }
  27. {}
  28. // empty share name means no share name
  29. // $share//topic_filter is protocol error
  30. //
  31. // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901250
  32. // A Shared Subscription's Topic Filter MUST start with $share/ and MUST contain
  33. // a ShareName that is at least one character long [MQTT-4.8.2-1].
  34. buffer share_name;
  35. buffer topic_filter;
  36. subscribe_options subopts;
  37. };
  38. struct unsubscribe_entry {
  39. unsubscribe_entry(
  40. buffer share_name,
  41. buffer topic_filter)
  42. : share_name { force_move(share_name) },
  43. topic_filter { force_move(topic_filter) }
  44. {}
  45. unsubscribe_entry(
  46. buffer topic_filter)
  47. : topic_filter { force_move(topic_filter) }
  48. {}
  49. buffer share_name;
  50. buffer topic_filter;
  51. };
  52. } // namespace MQTT_NS
  53. #endif // MQTT_SUBSCRIBE_ENTRY_HPP