AWS IoT Device SDK C++ v2  1.34.0
AWS IoT Device SDK C++ v2
Mqtt5Packets.h
Go to the documentation of this file.
1 #pragma once
2 
10 
11 namespace Aws
12 {
13  namespace Crt
14  {
15  namespace Mqtt5
16  {
17 
24  {
25  public:
26  UserProperty(Crt::String key, Crt::String value) noexcept;
27 
28  const Crt::String &getName() const noexcept { return m_name; };
29  const Crt::String &getValue() const noexcept { return m_value; }
30 
31  ~UserProperty() noexcept;
32  UserProperty(const UserProperty &toCopy) noexcept;
33  UserProperty(UserProperty &&toMove) noexcept;
34  UserProperty &operator=(const UserProperty &toCopy) noexcept;
35  UserProperty &operator=(UserProperty &&toMove) noexcept;
36 
37  private:
38  Crt::String m_name;
39  Crt::String m_value;
40  };
41 
43  {
44  public:
45  virtual PacketType getType() = 0;
46  };
47 
53  {
54  public:
56  const aws_mqtt5_packet_publish_view &raw_options,
57  Allocator *allocator = ApiAllocator()) noexcept;
58  PublishPacket(Allocator *allocator = ApiAllocator()) noexcept;
60  Crt::String topic,
61  ByteCursor payload,
62  Mqtt5::QOS qos,
63  Allocator *allocator = ApiAllocator()) noexcept;
64  PacketType getType() override { return PacketType::AWS_MQTT5_PT_PUBLISH; };
65 
75  PublishPacket &WithPayload(ByteCursor payload) noexcept;
76 
85  PublishPacket &WithQOS(Mqtt5::QOS packetQOS) noexcept;
86 
95  PublishPacket &WithRetain(bool retain) noexcept;
96 
104  PublishPacket &WithTopic(Crt::String topic) noexcept;
105 
116  PublishPacket &WithPayloadFormatIndicator(PayloadFormatIndicator payloadFormat) noexcept;
117 
129  PublishPacket &WithMessageExpiryIntervalSec(uint32_t second) noexcept;
130 
137  PublishPacket &WithTopicAlias(uint16_t topicAlias) noexcept;
138 
148  PublishPacket &WithResponseTopic(ByteCursor responseTopic) noexcept;
149 
160  PublishPacket &WithCorrelationData(ByteCursor correlationData) noexcept;
161 
171  PublishPacket &WithUserProperties(const Vector<UserProperty> &userProperties) noexcept;
172 
182  PublishPacket &WithUserProperties(Vector<UserProperty> &&userProperties) noexcept;
183 
193  PublishPacket &WithUserProperty(UserProperty &&property) noexcept;
194 
195  bool initializeRawOptions(aws_mqtt5_packet_publish_view &raw_options) noexcept;
196 
205  const ByteCursor &getPayload() const noexcept;
206 
216  Mqtt5::QOS getQOS() const noexcept;
217 
227  bool getRetain() const noexcept;
228 
237  const Crt::String &getTopic() const noexcept;
238 
248  const Crt::Optional<PayloadFormatIndicator> &getPayloadFormatIndicator() const noexcept;
249 
264  const Crt::Optional<uint32_t> &getMessageExpiryIntervalSec() const noexcept;
265 
276  const Crt::Optional<uint16_t> &getTopicAlias() const noexcept;
277 
287  const Crt::Optional<ByteCursor> &getResponseTopic() const noexcept;
288 
298  const Crt::Optional<ByteCursor> &getCorrelationData() const noexcept;
299 
310  const Crt::Vector<uint32_t> &getSubscriptionIdentifiers() const noexcept;
311 
319  const Crt::Optional<ByteCursor> &getContentType() const noexcept;
320 
329  const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
330 
331  virtual ~PublishPacket();
332  PublishPacket(const PublishPacket &) = delete;
333  PublishPacket(PublishPacket &&) noexcept = delete;
334  PublishPacket &operator=(const PublishPacket &) = delete;
335  PublishPacket &operator=(PublishPacket &&) noexcept = delete;
336 
337  private:
338  Allocator *m_allocator;
339 
346  ByteCursor m_payload;
347 
355  Mqtt5::QOS m_qos;
356 
364  bool m_retain;
365 
373  Crt::String m_topicName;
374 
382  Crt::Optional<PayloadFormatIndicator> m_payloadFormatIndicator;
383 
396  Crt::Optional<uint32_t> m_messageExpiryIntervalSec;
397 
406  Crt::Optional<uint16_t> m_topicAlias;
407 
415  Crt::Optional<ByteCursor> m_responseTopic;
416 
424  Crt::Optional<ByteCursor> m_correlationData;
425 
432  Crt::Vector<UserProperty> m_userProperties;
433 
435  // The following parameters are ignored when building publish operations */
437 
446  Crt::Vector<uint32_t> m_subscriptionIdentifiers;
447 
453  Crt::Optional<ByteCursor> m_contentType;
454 
456  // Underlying data storage for internal use
458  ByteBuf m_payloadStorage;
459  ByteBuf m_contentTypeStorage;
460  ByteBuf m_correlationDataStorage;
461  Crt::String m_responseTopicString;
462  struct aws_mqtt5_user_property *m_userPropertiesStorage;
463  };
464 
479  {
480  public:
482  const aws_mqtt5_negotiated_settings &negotiated_settings,
483 
484  Allocator *allocator = ApiAllocator()) noexcept;
485 
489  Mqtt5::QOS getMaximumQOS() const noexcept;
490 
494  uint32_t getSessionExpiryIntervalSec() const noexcept;
495 
500  uint16_t getReceiveMaximumFromServer() const noexcept;
501 
508  uint32_t getMaximumPacketSizeBytes() const noexcept;
509 
513  uint32_t getMaximumPacketSizeToServer() const noexcept;
514 
518  uint16_t getTopicAliasMaximumToServer() const noexcept;
519 
523  uint16_t getTopicAliasMaximumToClient() const noexcept;
524 
532  uint16_t getServerKeepAliveSec() const noexcept;
533 
543  uint16_t getServerKeepAlive() const noexcept;
544 
548  bool getRetainAvailable() const noexcept;
549 
553  bool getWildcardSubscriptionsAvailable() const noexcept;
554 
558  bool getSubscriptionIdentifiersAvailable() const noexcept;
559 
563  bool getSharedSubscriptionsAvailable() const noexcept;
564 
568  bool getRejoinedSession() const noexcept;
569 
578  const Crt::String &getClientId() const noexcept;
579 
580  virtual ~NegotiatedSettings() {};
582  NegotiatedSettings(NegotiatedSettings &&) noexcept = delete;
583  NegotiatedSettings &operator=(const NegotiatedSettings &) = delete;
584  NegotiatedSettings &operator=(NegotiatedSettings &&) noexcept = delete;
585 
586  private:
590  Mqtt5::QOS m_maximumQOS;
591 
595  uint32_t m_sessionExpiryIntervalSec;
596 
600  uint16_t m_receiveMaximumFromServer;
601 
605  uint32_t m_maximumPacketSizeBytes;
606 
610  uint16_t m_topicAliasMaximumToServer;
611 
615  uint16_t m_topicAliasMaximumToClient;
616 
622  uint16_t m_serverKeepAliveSec;
623 
627  bool m_retainAvailable;
628 
632  bool m_wildcardSubscriptionsAvailable;
633 
637  bool m_subscriptionIdentifiersAvailable;
638 
642  bool m_sharedSubscriptionsAvailable;
643 
647  bool m_rejoinedSession;
648 
655  Crt::String m_clientId;
656  };
657 
663  {
664  public:
665  /* Default constructor */
666  ConnectPacket(Allocator *allocator = ApiAllocator()) noexcept;
667 
668  /* The packet type */
669  PacketType getType() override { return PacketType::AWS_MQTT5_PT_CONNECT; };
670 
689  ConnectPacket &WithKeepAliveIntervalSec(uint16_t keepAliveInteralSeconds) noexcept;
690 
704  ConnectPacket &WithClientId(Crt::String clientId) noexcept;
705 
714  ConnectPacket &WithUserName(Crt::String username) noexcept;
715 
725  ConnectPacket &WithPassword(ByteCursor password) noexcept;
726 
742  ConnectPacket &WithSessionExpiryIntervalSec(uint32_t sessionExpiryIntervalSeconds) noexcept;
743 
756  ConnectPacket &WithRequestResponseInformation(bool requestResponseInformation) noexcept;
757 
770  ConnectPacket &WithRequestProblemInformation(bool requestProblemInformation) noexcept;
771 
783  ConnectPacket &WithReceiveMaximum(uint16_t receiveMaximum) noexcept;
784 
795  ConnectPacket &WithMaximumPacketSizeBytes(uint32_t maximumPacketSizeBytes) noexcept;
796 
810  ConnectPacket &WithWillDelayIntervalSec(uint32_t willDelayIntervalSeconds) noexcept;
811 
823  ConnectPacket &WithWill(std::shared_ptr<PublishPacket> will) noexcept;
824 
834  ConnectPacket &WithUserProperties(const Vector<UserProperty> &userProperties) noexcept;
835 
845  ConnectPacket &WithUserProperties(Vector<UserProperty> &&userProperties) noexcept;
846 
856  ConnectPacket &WithUserProperty(UserProperty &&property) noexcept;
857 
858  /********************************************
859  * Access Functions
860  ********************************************/
861 
875  uint16_t getKeepAliveIntervalSec() const noexcept;
876 
889  const Crt::String &getClientId() const noexcept;
890 
898  const Crt::Optional<Crt::String> &getUsername() const noexcept;
899 
907  const Crt::Optional<Crt::ByteCursor> &getPassword() const noexcept;
908 
923  const Crt::Optional<uint32_t> &getSessionExpiryIntervalSec() const noexcept;
924 
935  const Crt::Optional<bool> &getRequestResponseInformation() const noexcept;
936 
947  const Crt::Optional<bool> &getRequestProblemInformation() const noexcept;
948 
958  const Crt::Optional<uint16_t> &getReceiveMaximum() const noexcept;
959 
971  const Crt::Optional<uint32_t> &getMaximumPacketSizeBytes() const noexcept;
972 
982  const Crt::Optional<uint32_t> &getMaximumPacketSizeToServer() const noexcept;
983 
996  const Crt::Optional<uint32_t> &getWillDelayIntervalSec() const noexcept;
997 
1008  const Crt::Optional<std::shared_ptr<PublishPacket>> &getWill() const noexcept;
1009 
1018  const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
1019 
1028  bool initializeRawOptions(aws_mqtt5_packet_connect_view &raw_options, Allocator *allocator) noexcept;
1029 
1030  virtual ~ConnectPacket();
1031  ConnectPacket(const ConnectPacket &) = delete;
1032  ConnectPacket(ConnectPacket &&) noexcept = delete;
1033  ConnectPacket &operator=(const ConnectPacket &) = delete;
1034  ConnectPacket &operator=(ConnectPacket &&) noexcept = delete;
1035 
1036  private:
1037  Allocator *m_allocator;
1038 
1049  uint16_t m_keepAliveIntervalSec;
1050 
1061  Crt::String m_clientId;
1062 
1068  Crt::Optional<Crt::String> m_username;
1069 
1075  Crt::Optional<ByteCursor> m_password;
1076 
1088  Crt::Optional<uint32_t> m_sessionExpiryIntervalSec;
1089 
1098  Crt::Optional<bool> m_requestResponseInformation;
1099 
1107  Crt::Optional<bool> m_requestProblemInformation;
1108 
1116  Crt::Optional<uint16_t> m_receiveMaximum;
1117 
1125  Crt::Optional<uint32_t> m_maximumPacketSizeBytes;
1126 
1136  Crt::Optional<uint32_t> m_willDelayIntervalSeconds;
1137 
1145  Crt::Optional<std::shared_ptr<PublishPacket>> m_will;
1146 
1153  Crt::Vector<UserProperty> m_userProperties;
1154 
1156  // Underlying data storage for internal use
1158  struct aws_byte_cursor m_usernameCursor;
1159  struct aws_byte_buf m_passowrdStorage;
1160  struct aws_mqtt5_packet_publish_view m_willStorage;
1161  struct aws_mqtt5_user_property *m_userPropertiesStorage;
1162  uint8_t m_requestResponseInformationStorage;
1163  uint8_t m_requestProblemInformationStorage;
1164  };
1165 
1171  {
1172  public:
1173  ConnAckPacket(
1174  const aws_mqtt5_packet_connack_view &packet,
1175  Allocator *allocator = ApiAllocator()) noexcept;
1176 
1177  /* The packet type */
1178  PacketType getType() override { return PacketType::AWS_MQTT5_PT_CONNACK; };
1179 
1188  bool getSessionPresent() const noexcept;
1189 
1198  ConnectReasonCode getReasonCode() const noexcept;
1199 
1210  const Crt::Optional<uint32_t> &getSessionExpiryIntervalSec() const noexcept;
1211 
1224  const Crt::Optional<uint32_t> &getSessionExpiryInterval() const noexcept;
1225 
1236  const Crt::Optional<uint16_t> &getReceiveMaximum() const noexcept;
1237 
1246  const Crt::Optional<QOS> &getMaximumQOS() const noexcept;
1247 
1257  const Crt::Optional<bool> &getRetainAvailable() const noexcept;
1258 
1268  const Crt::Optional<uint32_t> &getMaximumPacketSize() const noexcept;
1269 
1279  const Crt::Optional<String> &getAssignedClientIdentifier() const noexcept;
1280 
1289  const Crt::Optional<uint16_t> getTopicAliasMaximum() const noexcept;
1290 
1299  const Crt::Optional<String> &getReasonString() const noexcept;
1300 
1309  const Vector<UserProperty> &getUserProperty() const noexcept;
1310 
1320  const Crt::Optional<bool> &getWildcardSubscriptionsAvailable() const noexcept;
1321 
1331  const Crt::Optional<bool> &getSubscriptionIdentifiersAvailable() const noexcept;
1332 
1342  const Crt::Optional<bool> &getSharedSubscriptionsAvailable() const noexcept;
1343 
1353  const Crt::Optional<uint16_t> &getServerKeepAliveSec() const noexcept;
1354 
1365  const Crt::Optional<uint16_t> &getServerKeepAlive() const noexcept;
1366 
1376  const Crt::Optional<String> &getResponseInformation() const noexcept;
1377 
1389  const Crt::Optional<String> &getServerReference() const noexcept;
1390 
1391  virtual ~ConnAckPacket() {};
1392  ConnAckPacket(const ConnAckPacket &) = delete;
1393  ConnAckPacket(ConnAckPacket &&) noexcept = delete;
1394  ConnAckPacket &operator=(const ConnAckPacket &) = delete;
1395  ConnAckPacket &operator=(ConnAckPacket &&) noexcept = delete;
1396 
1397  private:
1404  bool m_sessionPresent;
1405 
1412  ConnectReasonCode m_reasonCode;
1413 
1421  Crt::Optional<uint32_t> m_sessionExpiryIntervalSec;
1422 
1430  Crt::Optional<uint16_t> m_receiveMaximum;
1431 
1437  Crt::Optional<QOS> m_maximumQOS;
1438 
1446  Crt::Optional<bool> m_retainAvailable;
1447 
1455  Crt::Optional<uint32_t> m_maximumPacketSize;
1456 
1464  Crt::Optional<String> m_assignedClientIdentifier;
1465 
1472  Crt::Optional<uint16_t> m_topicAliasMaximum;
1473 
1480  Crt::Optional<String> m_reasonString;
1481 
1489  Crt::Optional<bool> m_wildcardSubscriptionsAvailable;
1490 
1498  Crt::Optional<bool> m_subscriptionIdentifiersAvailable;
1499 
1507  Crt::Optional<bool> m_sharedSubscriptionsAvailable;
1508 
1516  Crt::Optional<uint16_t> m_serverKeepAliveSec;
1517 
1525  Crt::Optional<String> m_responseInformation;
1526 
1535  Crt::Optional<String> m_serverReference;
1536 
1543  Vector<UserProperty> m_userProperties;
1544  };
1545 
1551  {
1552  public:
1553  DisconnectPacket(Allocator *allocator = ApiAllocator()) noexcept;
1555  const aws_mqtt5_packet_disconnect_view &raw_options,
1556  Allocator *allocator = ApiAllocator()) noexcept;
1557  /* The packet type */
1558  PacketType getType() override { return PacketType::AWS_MQTT5_PT_DISCONNECT; };
1559 
1560  bool initializeRawOptions(aws_mqtt5_packet_disconnect_view &raw_options) noexcept;
1561 
1571  DisconnectPacket &WithReasonCode(const DisconnectReasonCode reasonCode) noexcept;
1572 
1584  DisconnectPacket &WithSessionExpiryIntervalSec(const uint32_t sessionExpiryIntervalSeconds) noexcept;
1585 
1596  DisconnectPacket &WithReasonString(Crt::String reasonString) noexcept;
1597 
1610  DisconnectPacket &WithServerReference(Crt::String serverReference) noexcept;
1611 
1621  DisconnectPacket &WithUserProperties(const Vector<UserProperty> &userProperties) noexcept;
1622 
1632  DisconnectPacket &WithUserProperties(Vector<UserProperty> &&userProperties) noexcept;
1633 
1643  DisconnectPacket &WithUserProperty(UserProperty &&property) noexcept;
1644 
1653  DisconnectReasonCode getReasonCode() const noexcept;
1654 
1666  const Crt::Optional<uint32_t> &getSessionExpiryIntervalSec() const noexcept;
1667 
1676  const Crt::Optional<Crt::String> &getReasonString() const noexcept;
1677 
1689  const Crt::Optional<Crt::String> &getServerReference() const noexcept;
1690 
1699  const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
1700 
1701  virtual ~DisconnectPacket();
1703  DisconnectPacket(DisconnectPacket &&) noexcept = delete;
1704  DisconnectPacket &operator=(const DisconnectPacket &) = delete;
1705  DisconnectPacket &operator=(DisconnectPacket &&) noexcept = delete;
1706 
1707  private:
1708  Crt::Allocator *m_allocator;
1709 
1716  DisconnectReasonCode m_reasonCode;
1717 
1726  Crt::Optional<uint32_t> m_sessionExpiryIntervalSec;
1727 
1734  Crt::Optional<Crt::String> m_reasonString;
1735 
1744  Crt::Optional<Crt::String> m_serverReference;
1745 
1752  Crt::Vector<UserProperty> m_userProperties;
1753 
1755  // Underlying data storage for internal use
1757  struct aws_byte_cursor m_reasonStringCursor;
1758  struct aws_byte_cursor m_serverReferenceCursor;
1759  struct aws_mqtt5_user_property *m_userPropertiesStorage;
1760  };
1761 
1767  {
1768  public:
1769  PubAckPacket(
1770  const aws_mqtt5_packet_puback_view &packet,
1771  Allocator *allocator = ApiAllocator()) noexcept;
1772 
1773  PacketType getType() override { return PacketType::AWS_MQTT5_PT_PUBACK; };
1774 
1783  PubAckReasonCode getReasonCode() const noexcept;
1784 
1793  const Crt::Optional<Crt::String> &getReasonString() const noexcept;
1794 
1803  const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
1804 
1805  virtual ~PubAckPacket() {};
1806  PubAckPacket(const PubAckPacket &toCopy) noexcept = delete;
1807  PubAckPacket(PubAckPacket &&toMove) noexcept = delete;
1808  PubAckPacket &operator=(const PubAckPacket &toCopy) noexcept = delete;
1809  PubAckPacket &operator=(PubAckPacket &&toMove) noexcept = delete;
1810 
1811  private:
1818  PubAckReasonCode m_reasonCode;
1819 
1826  Crt::Optional<Crt::String> m_reasonString;
1827 
1834  Crt::Vector<UserProperty> m_userProperties;
1835  };
1836 
1844  {
1845  public:
1846  PublishResult(); // QoS 0 success
1847  PublishResult(std::shared_ptr<PubAckPacket> puback); // Qos 1 success
1848  PublishResult(int errorCode); // any failure
1849 
1855  bool wasSuccessful() const { return m_errorCode == 0; };
1856 
1862  int getErrorCode() const { return m_errorCode; };
1863 
1870  std::shared_ptr<IPacket> getAck() const { return m_ack; };
1871 
1872  ~PublishResult() noexcept;
1873  PublishResult(const PublishResult &toCopy) noexcept = delete;
1874  PublishResult(PublishResult &&toMove) noexcept = delete;
1875  PublishResult &operator=(const PublishResult &toCopy) noexcept = delete;
1876  PublishResult &operator=(PublishResult &&toMove) noexcept = delete;
1877 
1878  private:
1879  std::shared_ptr<IPacket> m_ack;
1880  int m_errorCode;
1881  };
1882 
1890  {
1891 
1892  public:
1893  Subscription(Allocator *allocator = ApiAllocator());
1894  Subscription(Crt::String topicFilter, Mqtt5::QOS qos, Allocator *allocator = ApiAllocator());
1895 
1905  Subscription &WithTopicFilter(Crt::String topicFilter) noexcept;
1906 
1917  Subscription &WithQOS(Mqtt5::QOS QOS) noexcept;
1918 
1929  Subscription &WithNoLocal(bool noLocal) noexcept;
1930 
1941  Subscription &WithRetainAsPublished(bool retain) noexcept;
1942 
1955  Subscription &WithRetain(bool retain) noexcept;
1956 
1967  Subscription &WithRetainHandlingType(RetainHandlingType retainHandlingType) noexcept;
1968 
1969  bool initializeRawOptions(aws_mqtt5_subscription_view &raw_options) const noexcept;
1970 
1971  virtual ~Subscription() {};
1972  Subscription(const Subscription &) noexcept;
1973  Subscription(Subscription &&) noexcept;
1974  Subscription &operator=(const Subscription &) noexcept;
1975  Subscription &operator=(Subscription &&) noexcept;
1976 
1977  private:
1978  Allocator *m_allocator;
1979 
1986  Crt::String m_topicFilter;
1987 
1994  Mqtt5::QOS m_qos;
1995 
2003  bool m_noLocal;
2004 
2012  bool m_retainAsPublished;
2013 
2021  RetainHandlingType m_retainHnadlingType;
2022  };
2023 
2029  {
2030  public:
2031  SubscribePacket(Allocator *allocator = ApiAllocator()) noexcept;
2032 
2033  /* The packet type */
2034  PacketType getType() override { return PacketType::AWS_MQTT5_PT_SUBSCRIBE; };
2035 
2045  SubscribePacket &WithUserProperties(const Vector<UserProperty> &userProperties) noexcept;
2046 
2056  SubscribePacket &WithUserProperties(Vector<UserProperty> &&userProperties) noexcept;
2057 
2067  SubscribePacket &WithUserProperty(UserProperty &&property) noexcept;
2068 
2079  SubscribePacket &WithSubscriptionIdentifier(uint32_t subscriptionIdentifier) noexcept;
2080 
2088  SubscribePacket &WithSubscriptions(const Vector<Subscription> &subscriptions) noexcept;
2089 
2097  SubscribePacket &WithSubscriptions(Crt::Vector<Subscription> &&subscriptions) noexcept;
2098 
2106  SubscribePacket &WithSubscription(Subscription &&subscription) noexcept;
2107 
2108  bool initializeRawOptions(aws_mqtt5_packet_subscribe_view &raw_options) noexcept;
2109 
2110  virtual ~SubscribePacket();
2111  SubscribePacket(const SubscribePacket &) noexcept = delete;
2112  SubscribePacket(SubscribePacket &&) noexcept = delete;
2113  SubscribePacket &operator=(const SubscribePacket &) noexcept = delete;
2114  SubscribePacket &operator=(SubscribePacket &&) noexcept = delete;
2115 
2116  private:
2117  Allocator *m_allocator;
2118 
2125  Crt::Vector<Subscription> m_subscriptions;
2126 
2134  Crt::Optional<uint32_t> m_subscriptionIdentifier;
2135 
2142  Crt::Vector<UserProperty> m_userProperties;
2143 
2145  // Underlying data storage for internal use
2147  struct aws_mqtt5_subscription_view *m_subscriptionViewStorage;
2148  struct aws_mqtt5_user_property *m_userPropertiesStorage;
2149  };
2150 
2156  {
2157  public:
2158  SubAckPacket(
2159  const aws_mqtt5_packet_suback_view &packet,
2160  Allocator *allocator = ApiAllocator()) noexcept;
2161 
2162  /* The packet type */
2163  PacketType getType() override { return PacketType::AWS_MQTT5_PT_SUBACK; };
2164 
2173  const Crt::Optional<Crt::String> &getReasonString() const noexcept;
2174 
2183  const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
2184 
2195  const Crt::Vector<SubAckReasonCode> &getReasonCodes() const noexcept;
2196 
2197  virtual ~SubAckPacket() { m_userProperties.clear(); };
2198  SubAckPacket(const SubAckPacket &) noexcept = delete;
2199  SubAckPacket(SubAckPacket &&) noexcept = delete;
2200  SubAckPacket &operator=(const SubAckPacket &) noexcept = delete;
2201  SubAckPacket &operator=(SubAckPacket &&) noexcept = delete;
2202 
2203  private:
2211  Crt::Vector<SubAckReasonCode> m_reasonCodes;
2212 
2219  Crt::Optional<Crt::String> m_reasonString;
2220 
2227  Crt::Vector<UserProperty> m_userProperties;
2228  };
2229 
2235  {
2236  public:
2237  UnsubscribePacket(Allocator *allocator = ApiAllocator()) noexcept;
2238 
2239  /* The packet type */
2240  PacketType getType() override { return PacketType::AWS_MQTT5_PT_UNSUBSCRIBE; };
2241 
2249  UnsubscribePacket &WithTopicFilter(Crt::String topicFilter) noexcept;
2250 
2258  UnsubscribePacket &WithTopicFilters(Crt::Vector<String> topicFilters) noexcept;
2259 
2269  UnsubscribePacket &WithUserProperties(const Vector<UserProperty> &userProperties) noexcept;
2270 
2280  UnsubscribePacket &WithUserProperties(Vector<UserProperty> &&userProperties) noexcept;
2281 
2291  UnsubscribePacket &WithUserProperty(UserProperty &&property) noexcept;
2292 
2293  bool initializeRawOptions(aws_mqtt5_packet_unsubscribe_view &raw_options) noexcept;
2294 
2295  virtual ~UnsubscribePacket();
2296  UnsubscribePacket(const UnsubscribePacket &) noexcept = delete;
2297  UnsubscribePacket(UnsubscribePacket &&) noexcept = delete;
2298  UnsubscribePacket &operator=(const UnsubscribePacket &) noexcept = delete;
2299  UnsubscribePacket &operator=(UnsubscribePacket &&) noexcept = delete;
2300 
2301  private:
2302  Allocator *m_allocator;
2303 
2310  Crt::Vector<String> m_topicFilters;
2311 
2318  Crt::Vector<UserProperty> m_userProperties;
2319 
2321  // Underlying data storage for internal use
2323  struct aws_array_list m_topicFiltersList;
2324  struct aws_mqtt5_user_property *m_userPropertiesStorage;
2325  };
2326 
2332  {
2333  public:
2335  const aws_mqtt5_packet_unsuback_view &packet,
2336  Allocator *allocator = ApiAllocator()) noexcept;
2337 
2338  /* The packet type */
2339  PacketType getType() override { return PacketType::AWS_MQTT5_PT_UNSUBACK; };
2340 
2349  const Crt::Optional<Crt::String> &getReasonString() const noexcept;
2350 
2359  const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
2360 
2371  const Crt::Vector<UnSubAckReasonCode> &getReasonCodes() const noexcept;
2372 
2373  virtual ~UnSubAckPacket() { m_userProperties.clear(); };
2374  UnSubAckPacket(const UnSubAckPacket &) noexcept = delete;
2375  UnSubAckPacket(UnSubAckPacket &&) noexcept = delete;
2376  UnSubAckPacket &operator=(const UnSubAckPacket &) noexcept = delete;
2377  UnSubAckPacket &operator=(UnSubAckPacket &&) noexcept = delete;
2378 
2379  private:
2386  Crt::Optional<Crt::String> m_reasonString;
2387 
2394  Crt::Vector<UserProperty> m_userProperties;
2395 
2403  Crt::Vector<UnSubAckReasonCode> m_reasonCodes;
2404  };
2405 
2406  } // namespace Mqtt5
2407  } // namespace Crt
2408 } // namespace Aws
Aws::Crt::Mqtt5::PubAckReasonCode
aws_mqtt5_puback_reason_code PubAckReasonCode
Definition: Mqtt5Types.h:127
Aws::Crt::Mqtt5::PublishPacket::getType
PacketType getType() override
Definition: Mqtt5Packets.h:64
Aws::Crt::Mqtt5::DisconnectPacket::getType
PacketType getType() override
Definition: Mqtt5Packets.h:1558
Aws::Crt::Mqtt5::IPacket::getType
virtual PacketType getType()=0
Aws::Crt::ApiAllocator
AWS_CRT_CPP_API Allocator * ApiAllocator() noexcept
Definition: Allocator.cpp:24
Aws::Crt::Mqtt5::PubAckPacket::operator=
PubAckPacket & operator=(const PubAckPacket &toCopy) noexcept=delete
Aws::Crt::Mqtt5::SubAckPacket::SubAckPacket
SubAckPacket(const SubAckPacket &) noexcept=delete
Aws::Crt::Mqtt5::UnSubAckPacket
Definition: Mqtt5Packets.h:2332
Aws::Crt::Mqtt5::SubAckPacket::getType
PacketType getType() override
Definition: Mqtt5Packets.h:2163
Aws::Crt::Mqtt5::PacketType
aws_mqtt5_packet_type PacketType
Definition: Mqtt5Types.h:308
Aws::Crt::Mqtt5::UnSubAckPacket::getType
PacketType getType() override
Definition: Mqtt5Packets.h:2339
Aws::Crt::Mqtt5::PublishPacket
Definition: Mqtt5Packets.h:53
Aws::Crt::Mqtt5::PublishResult::wasSuccessful
bool wasSuccessful() const
Definition: Mqtt5Packets.h:1855
Aws::Crt::Mqtt5::DisconnectPacket
Definition: Mqtt5Packets.h:1551
Aws::Crt::Mqtt5::PubAckPacket::PubAckPacket
PubAckPacket(PubAckPacket &&toMove) noexcept=delete
Aws::Crt::Mqtt5::NegotiatedSettings::~NegotiatedSettings
virtual ~NegotiatedSettings()
Definition: Mqtt5Packets.h:580
Aws::Crt::Mqtt5::PublishResult::getAck
std::shared_ptr< IPacket > getAck() const
Definition: Mqtt5Packets.h:1870
Aws::Crt::Mqtt5::SubAckPacket
Definition: Mqtt5Packets.h:2156
Aws::Crt::Mqtt5::UnsubscribePacket::UnsubscribePacket
UnsubscribePacket(UnsubscribePacket &&) noexcept=delete
Aws::Crt::Mqtt5::PayloadFormatIndicator
aws_mqtt5_payload_format_indicator PayloadFormatIndicator
Definition: Mqtt5Types.h:259
Aws::Crt::Mqtt5::ConnAckPacket::ConnAckPacket
ConnAckPacket(const ConnAckPacket &)=delete
Aws::Crt::Mqtt5::SubAckPacket::SubAckPacket
SubAckPacket(SubAckPacket &&) noexcept=delete
Aws::Crt::Mqtt5::ConnectPacket::getType
PacketType getType() override
Definition: Mqtt5Packets.h:669
Aws::Crt::Mqtt5::UnSubAckPacket::UnSubAckPacket
UnSubAckPacket(UnSubAckPacket &&) noexcept=delete
Aws::Crt::Mqtt5::SubscribePacket::SubscribePacket
SubscribePacket(SubscribePacket &&) noexcept=delete
Aws::Crt::Mqtt5::Subscription::~Subscription
virtual ~Subscription()
Definition: Mqtt5Packets.h:1971
Aws::Crt::Mqtt5::QOS
aws_mqtt5_qos QOS
Definition: Mqtt5Types.h:29
Mqtt5Client.h
Aws::Crt::Mqtt5::RetainHandlingType
aws_mqtt5_retain_handling_type RetainHandlingType
Definition: Mqtt5Types.h:278
Aws::Crt::Mqtt5::SubscribePacket
Definition: Mqtt5Packets.h:2029
Aws::Crt::Mqtt5::PubAckPacket::operator=
PubAckPacket & operator=(PubAckPacket &&toMove) noexcept=delete
Aws::Crt::Optional
Definition: Optional.h:18
Aws::Crt::Mqtt5::PubAckPacket::getType
PacketType getType() override
Definition: Mqtt5Packets.h:1773
Aws::Crt::Mqtt5::ConnAckPacket::getType
PacketType getType() override
Definition: Mqtt5Packets.h:1178
Aws::Crt::Mqtt5::UnsubscribePacket::UnsubscribePacket
UnsubscribePacket(const UnsubscribePacket &) noexcept=delete
Aws::Crt::Mqtt5::SubAckReasonCode
aws_mqtt5_suback_reason_code SubAckReasonCode
Definition: Mqtt5Types.h:148
Aws::Crt::Mqtt5::NegotiatedSettings
Definition: Mqtt5Packets.h:479
Aws::Crt::Mqtt5::Subscription
Definition: Mqtt5Packets.h:1890
Aws::Crt::Mqtt5::ConnAckPacket::ConnAckPacket
ConnAckPacket(ConnAckPacket &&) noexcept=delete
Aws::Crt::Mqtt5::UnSubAckPacket::UnSubAckPacket
UnSubAckPacket(const UnSubAckPacket &) noexcept=delete
Aws::Crt::Mqtt5::UserProperty::getName
const Crt::String & getName() const noexcept
Definition: Mqtt5Packets.h:28
Aws::Crt::Mqtt5::IPacket
Definition: Mqtt5Packets.h:43
Mqtt5Packets.h
Aws::Crt::Mqtt5::UserProperty::getValue
const Crt::String & getValue() const noexcept
Definition: Mqtt5Packets.h:29
Aws::Crt::Mqtt5::DisconnectReasonCode
aws_mqtt5_disconnect_reason_code DisconnectReasonCode
Definition: Mqtt5Types.h:107
Aws::Crt::Mqtt5::PublishResult::getErrorCode
int getErrorCode() const
Definition: Mqtt5Packets.h:1862
Aws::Crt::Mqtt5::ConnectPacket
Definition: Mqtt5Packets.h:663
Aws::Crt::Mqtt5::PublishResult
Definition: Mqtt5Packets.h:1844
Aws::Crt::Mqtt5::UnSubAckReasonCode
aws_mqtt5_unsuback_reason_code UnSubAckReasonCode
Definition: Mqtt5Types.h:169
Aws::Crt::Vector
std::vector< T, StlAllocator< T > > Vector
Definition: Types.h:53
Aws::Crt::Mqtt5::ConnectReasonCode
aws_mqtt5_connect_reason_code ConnectReasonCode
Definition: Mqtt5Types.h:65
Aws::Crt::ByteBuf
aws_byte_buf ByteBuf
Definition: Types.h:30
std
Definition: StringView.h:852
AWS_CRT_CPP_API
#define AWS_CRT_CPP_API
Definition: Exports.h:37
Aws
Definition: Allocator.h:11
Aws::Crt::Mqtt5::NegotiatedSettings::NegotiatedSettings
NegotiatedSettings(NegotiatedSettings &&) noexcept=delete
Aws::Crt::Mqtt5::UnsubscribePacket
Definition: Mqtt5Packets.h:2235
Aws::Crt::ByteCursor
aws_byte_cursor ByteCursor
Definition: Types.h:31
Aws::Crt::Mqtt5::PubAckPacket::PubAckPacket
PubAckPacket(const PubAckPacket &toCopy) noexcept=delete
Aws::Crt::Allocator
aws_allocator Allocator
Definition: Allocator.h:14
Aws::Crt::Mqtt5::NegotiatedSettings::NegotiatedSettings
NegotiatedSettings(const NegotiatedSettings &)=delete
Aws::Crt::Mqtt5::UserProperty
Definition: Mqtt5Packets.h:24
Aws::Crt::Mqtt5::UnsubscribePacket::getType
PacketType getType() override
Definition: Mqtt5Packets.h:2240
Aws::Crt::Mqtt5::PubAckPacket
Definition: Mqtt5Packets.h:1767
Mqtt5Types.h
Aws::Crt::Mqtt5::SubscribePacket::SubscribePacket
SubscribePacket(const SubscribePacket &) noexcept=delete
Aws::Crt::String
std::basic_string< char, std::char_traits< char >, StlAllocator< char > > String
Definition: Types.h:45
Aws::Crt::Mqtt5::SubscribePacket::getType
PacketType getType() override
Definition: Mqtt5Packets.h:2034
Aws::Crt::Mqtt5::ConnAckPacket
Definition: Mqtt5Packets.h:1171