aws-crt-cpp
C++ wrapper around the aws-c-* libraries. Provides Cross-Platform Transport Protocols and SSL/TLS implementations for C++.
Loading...
Searching...
No Matches
Mqtt5Packets.h
Go to the documentation of this file.
1#pragma once
9
10namespace Aws
11{
12 namespace Crt
13 {
14 namespace Mqtt5
15 {
16
23 {
24 public:
25 UserProperty(const Crt::String &name, const Crt::String &value) noexcept;
26 UserProperty(Crt::String &&name, 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 bool operator==(const UserProperty &other) const
32 {
33 return m_name == other.m_name && m_value == other.m_value;
34 }
35
36 private:
37 Crt::String m_name;
38 Crt::String m_value;
39 };
40
42 {
43 public:
44 virtual ~IPacket() = default;
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
169 PublishPacket &WithContentType(ByteCursor contentType) noexcept;
170
180 PublishPacket &WithUserProperties(const Vector<UserProperty> &userProperties) noexcept;
181
191 PublishPacket &WithUserProperties(Vector<UserProperty> &&userProperties) noexcept;
192
202 PublishPacket &WithUserProperty(UserProperty &&property) noexcept;
203
204 bool initializeRawOptions(aws_mqtt5_packet_publish_view &raw_options) noexcept;
205
214 const ByteCursor &getPayload() const noexcept;
215
225 Mqtt5::QOS getQOS() const noexcept;
226
236 bool getRetain() const noexcept;
237
246 const Crt::String &getTopic() const noexcept;
247
257 const Crt::Optional<PayloadFormatIndicator> &getPayloadFormatIndicator() const noexcept;
258
273 const Crt::Optional<uint32_t> &getMessageExpiryIntervalSec() const noexcept;
274
285 const Crt::Optional<uint16_t> &getTopicAlias() const noexcept;
286
296 const Crt::Optional<ByteCursor> &getResponseTopic() const noexcept;
297
307 const Crt::Optional<ByteCursor> &getCorrelationData() const noexcept;
308
319 const Crt::Vector<uint32_t> &getSubscriptionIdentifiers() const noexcept;
320
328 const Crt::Optional<ByteCursor> &getContentType() const noexcept;
329
338 const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
339
340 virtual ~PublishPacket();
341 PublishPacket(const PublishPacket &) = delete;
342 PublishPacket(PublishPacket &&) noexcept = delete;
343 PublishPacket &operator=(const PublishPacket &) = delete;
344 PublishPacket &operator=(PublishPacket &&) noexcept = delete;
345
346 private:
347 Allocator *m_allocator;
348
355 ByteCursor m_payload;
356
364 Mqtt5::QOS m_qos;
365
373 bool m_retain;
374
382 Crt::String m_topicName;
383
391 Crt::Optional<PayloadFormatIndicator> m_payloadFormatIndicator;
392
405 Crt::Optional<uint32_t> m_messageExpiryIntervalSec;
406
415 Crt::Optional<uint16_t> m_topicAlias;
416
424 Crt::Optional<ByteCursor> m_responseTopic;
425
433 Crt::Optional<ByteCursor> m_correlationData;
434
441 Crt::Vector<UserProperty> m_userProperties;
442
444 // The following parameters are ignored when building publish operations */
446
455 Crt::Vector<uint32_t> m_subscriptionIdentifiers;
456
462 Crt::Optional<ByteCursor> m_contentType;
463
465 // Underlying data storage for internal use
467 ByteBuf m_payloadStorage;
468 ByteBuf m_contentTypeStorage;
469 ByteBuf m_correlationDataStorage;
470 Crt::String m_responseTopicString;
471 struct aws_mqtt5_user_property *m_userPropertiesStorage;
472 };
473
488 {
489 public:
491 const aws_mqtt5_negotiated_settings &negotiated_settings,
492
493 Allocator *allocator = ApiAllocator()) noexcept;
494
498 Mqtt5::QOS getMaximumQOS() const noexcept;
499
503 uint32_t getSessionExpiryIntervalSec() const noexcept;
504
509 uint16_t getReceiveMaximumFromServer() const noexcept;
510
517 uint32_t getMaximumPacketSizeBytes() const noexcept;
518
522 uint32_t getMaximumPacketSizeToServer() const noexcept;
523
527 uint16_t getTopicAliasMaximumToServer() const noexcept;
528
532 uint16_t getTopicAliasMaximumToClient() const noexcept;
533
541 uint16_t getServerKeepAliveSec() const noexcept;
542
552 uint16_t getServerKeepAlive() const noexcept;
553
557 bool getRetainAvailable() const noexcept;
558
562 bool getWildcardSubscriptionsAvailable() const noexcept;
563
567 bool getSubscriptionIdentifiersAvailable() const noexcept;
568
572 bool getSharedSubscriptionsAvailable() const noexcept;
573
577 bool getRejoinedSession() const noexcept;
578
587 const Crt::String &getClientId() const noexcept;
588
592 NegotiatedSettings &operator=(const NegotiatedSettings &) = delete;
593 NegotiatedSettings &operator=(NegotiatedSettings &&) noexcept = delete;
594
595 private:
599 Mqtt5::QOS m_maximumQOS;
600
604 uint32_t m_sessionExpiryIntervalSec;
605
609 uint16_t m_receiveMaximumFromServer;
610
614 uint32_t m_maximumPacketSizeBytes;
615
619 uint16_t m_topicAliasMaximumToServer;
620
624 uint16_t m_topicAliasMaximumToClient;
625
631 uint16_t m_serverKeepAliveSec;
632
636 bool m_retainAvailable;
637
641 bool m_wildcardSubscriptionsAvailable;
642
646 bool m_subscriptionIdentifiersAvailable;
647
651 bool m_sharedSubscriptionsAvailable;
652
656 bool m_rejoinedSession;
657
664 Crt::String m_clientId;
665 };
666
672 {
673 public:
674 /* Default constructor */
675 ConnectPacket(Allocator *allocator = ApiAllocator()) noexcept;
676
677 /* The packet type */
678 PacketType getType() override { return PacketType::AWS_MQTT5_PT_CONNECT; };
679
698 ConnectPacket &WithKeepAliveIntervalSec(uint16_t keepAliveInteralSeconds) noexcept;
699
713 ConnectPacket &WithClientId(Crt::String clientId) noexcept;
714
723 ConnectPacket &WithUserName(Crt::String username) noexcept;
724
734 ConnectPacket &WithPassword(ByteCursor password) noexcept;
735
751 ConnectPacket &WithSessionExpiryIntervalSec(uint32_t sessionExpiryIntervalSeconds) noexcept;
752
765 ConnectPacket &WithRequestResponseInformation(bool requestResponseInformation) noexcept;
766
779 ConnectPacket &WithRequestProblemInformation(bool requestProblemInformation) noexcept;
780
792 ConnectPacket &WithReceiveMaximum(uint16_t receiveMaximum) noexcept;
793
804 ConnectPacket &WithMaximumPacketSizeBytes(uint32_t maximumPacketSizeBytes) noexcept;
805
819 ConnectPacket &WithWillDelayIntervalSec(uint32_t willDelayIntervalSeconds) noexcept;
820
832 ConnectPacket &WithWill(std::shared_ptr<PublishPacket> will) noexcept;
833
843 ConnectPacket &WithUserProperties(const Vector<UserProperty> &userProperties) noexcept;
844
854 ConnectPacket &WithUserProperties(Vector<UserProperty> &&userProperties) noexcept;
855
865 ConnectPacket &WithUserProperty(UserProperty &&property) noexcept;
866
867 /********************************************
868 * Access Functions
869 ********************************************/
870
884 uint16_t getKeepAliveIntervalSec() const noexcept;
885
898 const Crt::String &getClientId() const noexcept;
899
907 const Crt::Optional<Crt::String> &getUsername() const noexcept;
908
916 const Crt::Optional<Crt::ByteCursor> &getPassword() const noexcept;
917
932 const Crt::Optional<uint32_t> &getSessionExpiryIntervalSec() const noexcept;
933
944 const Crt::Optional<bool> &getRequestResponseInformation() const noexcept;
945
956 const Crt::Optional<bool> &getRequestProblemInformation() const noexcept;
957
967 const Crt::Optional<uint16_t> &getReceiveMaximum() const noexcept;
968
980 const Crt::Optional<uint32_t> &getMaximumPacketSizeBytes() const noexcept;
981
991 const Crt::Optional<uint32_t> &getMaximumPacketSizeToServer() const noexcept;
992
1005 const Crt::Optional<uint32_t> &getWillDelayIntervalSec() const noexcept;
1006
1017 const Crt::Optional<std::shared_ptr<PublishPacket>> &getWill() const noexcept;
1018
1027 const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
1028
1037 bool initializeRawOptions(aws_mqtt5_packet_connect_view &raw_options, Allocator *allocator) noexcept;
1038
1039 virtual ~ConnectPacket();
1040 ConnectPacket(const ConnectPacket &) = delete;
1041 ConnectPacket(ConnectPacket &&) noexcept = delete;
1042 ConnectPacket &operator=(const ConnectPacket &) = delete;
1043 ConnectPacket &operator=(ConnectPacket &&) noexcept = delete;
1044
1045 private:
1046 Allocator *m_allocator;
1047
1058 uint16_t m_keepAliveIntervalSec;
1059
1070 Crt::String m_clientId;
1071
1077 Crt::Optional<Crt::String> m_username;
1078
1084 Crt::Optional<ByteCursor> m_password;
1085
1097 Crt::Optional<uint32_t> m_sessionExpiryIntervalSec;
1098
1107 Crt::Optional<bool> m_requestResponseInformation;
1108
1116 Crt::Optional<bool> m_requestProblemInformation;
1117
1125 Crt::Optional<uint16_t> m_receiveMaximum;
1126
1134 Crt::Optional<uint32_t> m_maximumPacketSizeBytes;
1135
1145 Crt::Optional<uint32_t> m_willDelayIntervalSeconds;
1146
1154 Crt::Optional<std::shared_ptr<PublishPacket>> m_will;
1155
1162 Crt::Vector<UserProperty> m_userProperties;
1163
1165 // Underlying data storage for internal use
1167 struct aws_byte_cursor m_usernameCursor;
1168 struct aws_byte_buf m_passowrdStorage;
1169 struct aws_mqtt5_packet_publish_view m_willStorage;
1170 struct aws_mqtt5_user_property *m_userPropertiesStorage;
1171 uint8_t m_requestResponseInformationStorage;
1172 uint8_t m_requestProblemInformationStorage;
1173 };
1174
1180 {
1181 public:
1183 const aws_mqtt5_packet_connack_view &packet,
1184 Allocator *allocator = ApiAllocator()) noexcept;
1185
1186 /* The packet type */
1187 PacketType getType() override { return PacketType::AWS_MQTT5_PT_CONNACK; };
1188
1197 bool getSessionPresent() const noexcept;
1198
1207 ConnectReasonCode getReasonCode() const noexcept;
1208
1219 const Crt::Optional<uint32_t> &getSessionExpiryIntervalSec() const noexcept;
1220
1233 const Crt::Optional<uint32_t> &getSessionExpiryInterval() const noexcept;
1234
1245 const Crt::Optional<uint16_t> &getReceiveMaximum() const noexcept;
1246
1255 const Crt::Optional<QOS> &getMaximumQOS() const noexcept;
1256
1266 const Crt::Optional<bool> &getRetainAvailable() const noexcept;
1267
1277 const Crt::Optional<uint32_t> &getMaximumPacketSize() const noexcept;
1278
1288 const Crt::Optional<String> &getAssignedClientIdentifier() const noexcept;
1289
1298 const Crt::Optional<uint16_t> getTopicAliasMaximum() const noexcept;
1299
1308 const Crt::Optional<String> &getReasonString() const noexcept;
1309
1318 const Vector<UserProperty> &getUserProperty() const noexcept;
1319
1329 const Crt::Optional<bool> &getWildcardSubscriptionsAvailable() const noexcept;
1330
1340 const Crt::Optional<bool> &getSubscriptionIdentifiersAvailable() const noexcept;
1341
1351 const Crt::Optional<bool> &getSharedSubscriptionsAvailable() const noexcept;
1352
1362 const Crt::Optional<uint16_t> &getServerKeepAliveSec() const noexcept;
1363
1374 const Crt::Optional<uint16_t> &getServerKeepAlive() const noexcept;
1375
1385 const Crt::Optional<String> &getResponseInformation() const noexcept;
1386
1398 const Crt::Optional<String> &getServerReference() const noexcept;
1399
1400 virtual ~ConnAckPacket() {};
1401 ConnAckPacket(const ConnAckPacket &) = delete;
1402 ConnAckPacket(ConnAckPacket &&) noexcept = delete;
1403 ConnAckPacket &operator=(const ConnAckPacket &) = delete;
1404 ConnAckPacket &operator=(ConnAckPacket &&) noexcept = delete;
1405
1406 private:
1413 bool m_sessionPresent;
1414
1421 ConnectReasonCode m_reasonCode;
1422
1430 Crt::Optional<uint32_t> m_sessionExpiryIntervalSec;
1431
1439 Crt::Optional<uint16_t> m_receiveMaximum;
1440
1446 Crt::Optional<QOS> m_maximumQOS;
1447
1455 Crt::Optional<bool> m_retainAvailable;
1456
1464 Crt::Optional<uint32_t> m_maximumPacketSize;
1465
1473 Crt::Optional<String> m_assignedClientIdentifier;
1474
1481 Crt::Optional<uint16_t> m_topicAliasMaximum;
1482
1489 Crt::Optional<String> m_reasonString;
1490
1498 Crt::Optional<bool> m_wildcardSubscriptionsAvailable;
1499
1507 Crt::Optional<bool> m_subscriptionIdentifiersAvailable;
1508
1516 Crt::Optional<bool> m_sharedSubscriptionsAvailable;
1517
1525 Crt::Optional<uint16_t> m_serverKeepAliveSec;
1526
1534 Crt::Optional<String> m_responseInformation;
1535
1544 Crt::Optional<String> m_serverReference;
1545
1552 Vector<UserProperty> m_userProperties;
1553 };
1554
1560 {
1561 public:
1562 DisconnectPacket(Allocator *allocator = ApiAllocator()) noexcept;
1564 const aws_mqtt5_packet_disconnect_view &raw_options,
1565 Allocator *allocator = ApiAllocator()) noexcept;
1566 /* The packet type */
1567 PacketType getType() override { return PacketType::AWS_MQTT5_PT_DISCONNECT; };
1568
1569 bool initializeRawOptions(aws_mqtt5_packet_disconnect_view &raw_options) noexcept;
1570
1580 DisconnectPacket &WithReasonCode(const DisconnectReasonCode reasonCode) noexcept;
1581
1593 DisconnectPacket &WithSessionExpiryIntervalSec(const uint32_t sessionExpiryIntervalSeconds) noexcept;
1594
1605 DisconnectPacket &WithReasonString(Crt::String reasonString) noexcept;
1606
1619 DisconnectPacket &WithServerReference(Crt::String serverReference) noexcept;
1620
1630 DisconnectPacket &WithUserProperties(const Vector<UserProperty> &userProperties) noexcept;
1631
1641 DisconnectPacket &WithUserProperties(Vector<UserProperty> &&userProperties) noexcept;
1642
1652 DisconnectPacket &WithUserProperty(UserProperty &&property) noexcept;
1653
1662 DisconnectReasonCode getReasonCode() const noexcept;
1663
1675 const Crt::Optional<uint32_t> &getSessionExpiryIntervalSec() const noexcept;
1676
1685 const Crt::Optional<Crt::String> &getReasonString() const noexcept;
1686
1698 const Crt::Optional<Crt::String> &getServerReference() const noexcept;
1699
1708 const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
1709
1710 virtual ~DisconnectPacket();
1712 DisconnectPacket(DisconnectPacket &&) noexcept = delete;
1713 DisconnectPacket &operator=(const DisconnectPacket &) = delete;
1714 DisconnectPacket &operator=(DisconnectPacket &&) noexcept = delete;
1715
1716 private:
1717 Crt::Allocator *m_allocator;
1718
1725 DisconnectReasonCode m_reasonCode;
1726
1735 Crt::Optional<uint32_t> m_sessionExpiryIntervalSec;
1736
1743 Crt::Optional<Crt::String> m_reasonString;
1744
1753 Crt::Optional<Crt::String> m_serverReference;
1754
1761 Crt::Vector<UserProperty> m_userProperties;
1762
1764 // Underlying data storage for internal use
1766 struct aws_byte_cursor m_reasonStringCursor;
1767 struct aws_byte_cursor m_serverReferenceCursor;
1768 struct aws_mqtt5_user_property *m_userPropertiesStorage;
1769 };
1770
1776 {
1777 public:
1779 const aws_mqtt5_packet_puback_view &packet,
1780 Allocator *allocator = ApiAllocator()) noexcept;
1781
1782 PacketType getType() override { return PacketType::AWS_MQTT5_PT_PUBACK; };
1783
1792 PubAckReasonCode getReasonCode() const noexcept;
1793
1802 const Crt::Optional<Crt::String> &getReasonString() const noexcept;
1803
1812 const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
1813
1814 virtual ~PubAckPacket() {};
1815 PubAckPacket(const PubAckPacket &toCopy) noexcept = delete;
1816 PubAckPacket(PubAckPacket &&toMove) noexcept = delete;
1817 PubAckPacket &operator=(const PubAckPacket &toCopy) noexcept = delete;
1818 PubAckPacket &operator=(PubAckPacket &&toMove) noexcept = delete;
1819
1820 private:
1827 PubAckReasonCode m_reasonCode;
1828
1835 Crt::Optional<Crt::String> m_reasonString;
1836
1843 Crt::Vector<UserProperty> m_userProperties;
1844 };
1845
1853 {
1854 public:
1855 PublishResult(); // QoS 0 success
1856 PublishResult(std::shared_ptr<PubAckPacket> puback); // Qos 1 success
1857 PublishResult(int errorCode); // any failure
1858
1864 bool wasSuccessful() const { return m_errorCode == 0; };
1865
1871 int getErrorCode() const { return m_errorCode; };
1872
1879 std::shared_ptr<IPacket> getAck() const { return m_ack; };
1880
1881 ~PublishResult() noexcept;
1882 PublishResult(const PublishResult &toCopy) noexcept = delete;
1883 PublishResult(PublishResult &&toMove) noexcept = delete;
1884 PublishResult &operator=(const PublishResult &toCopy) noexcept = delete;
1885 PublishResult &operator=(PublishResult &&toMove) noexcept = delete;
1886
1887 private:
1888 std::shared_ptr<IPacket> m_ack;
1889 int m_errorCode;
1890 };
1891
1899 {
1900
1901 public:
1902 Subscription(Allocator *allocator = ApiAllocator());
1903 Subscription(Crt::String topicFilter, Mqtt5::QOS qos, Allocator *allocator = ApiAllocator());
1904
1914 Subscription &WithTopicFilter(Crt::String topicFilter) noexcept;
1915
1926 Subscription &WithQOS(Mqtt5::QOS QOS) noexcept;
1927
1938 Subscription &WithNoLocal(bool noLocal) noexcept;
1939
1950 Subscription &WithRetainAsPublished(bool retain) noexcept;
1951
1964 Subscription &WithRetain(bool retain) noexcept;
1965
1976 Subscription &WithRetainHandlingType(RetainHandlingType retainHandlingType) noexcept;
1977
1978 bool initializeRawOptions(aws_mqtt5_subscription_view &raw_options) const noexcept;
1979
1980 virtual ~Subscription() {};
1981 Subscription(const Subscription &) noexcept;
1982 Subscription(Subscription &&) noexcept;
1983 Subscription &operator=(const Subscription &) noexcept;
1984 Subscription &operator=(Subscription &&) noexcept;
1985
1986 private:
1987 Allocator *m_allocator;
1988
1995 Crt::String m_topicFilter;
1996
2003 Mqtt5::QOS m_qos;
2004
2012 bool m_noLocal;
2013
2021 bool m_retainAsPublished;
2022
2030 RetainHandlingType m_retainHnadlingType;
2031 };
2032
2038 {
2039 public:
2040 SubscribePacket(Allocator *allocator = ApiAllocator()) noexcept;
2041
2042 /* The packet type */
2043 PacketType getType() override { return PacketType::AWS_MQTT5_PT_SUBSCRIBE; };
2044
2054 SubscribePacket &WithUserProperties(const Vector<UserProperty> &userProperties) noexcept;
2055
2065 SubscribePacket &WithUserProperties(Vector<UserProperty> &&userProperties) noexcept;
2066
2076 SubscribePacket &WithUserProperty(UserProperty &&property) noexcept;
2077
2088 SubscribePacket &WithSubscriptionIdentifier(uint32_t subscriptionIdentifier) noexcept;
2089
2097 SubscribePacket &WithSubscriptions(const Vector<Subscription> &subscriptions) noexcept;
2098
2106 SubscribePacket &WithSubscriptions(Crt::Vector<Subscription> &&subscriptions) noexcept;
2107
2115 SubscribePacket &WithSubscription(Subscription &&subscription) noexcept;
2116
2117 bool initializeRawOptions(aws_mqtt5_packet_subscribe_view &raw_options) noexcept;
2118
2119 virtual ~SubscribePacket();
2120 SubscribePacket(const SubscribePacket &) noexcept = delete;
2121 SubscribePacket(SubscribePacket &&) noexcept = delete;
2122 SubscribePacket &operator=(const SubscribePacket &) noexcept = delete;
2123 SubscribePacket &operator=(SubscribePacket &&) noexcept = delete;
2124
2125 private:
2126 Allocator *m_allocator;
2127
2134 Crt::Vector<Subscription> m_subscriptions;
2135
2143 Crt::Optional<uint32_t> m_subscriptionIdentifier;
2144
2151 Crt::Vector<UserProperty> m_userProperties;
2152
2154 // Underlying data storage for internal use
2156 struct aws_mqtt5_subscription_view *m_subscriptionViewStorage;
2157 struct aws_mqtt5_user_property *m_userPropertiesStorage;
2158 };
2159
2165 {
2166 public:
2168 const aws_mqtt5_packet_suback_view &packet,
2169 Allocator *allocator = ApiAllocator()) noexcept;
2170
2171 /* The packet type */
2172 PacketType getType() override { return PacketType::AWS_MQTT5_PT_SUBACK; };
2173
2182 const Crt::Optional<Crt::String> &getReasonString() const noexcept;
2183
2192 const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
2193
2204 const Crt::Vector<SubAckReasonCode> &getReasonCodes() const noexcept;
2205
2206 virtual ~SubAckPacket() { m_userProperties.clear(); };
2207 SubAckPacket(const SubAckPacket &) noexcept = delete;
2208 SubAckPacket(SubAckPacket &&) noexcept = delete;
2209 SubAckPacket &operator=(const SubAckPacket &) noexcept = delete;
2210 SubAckPacket &operator=(SubAckPacket &&) noexcept = delete;
2211
2212 private:
2220 Crt::Vector<SubAckReasonCode> m_reasonCodes;
2221
2228 Crt::Optional<Crt::String> m_reasonString;
2229
2236 Crt::Vector<UserProperty> m_userProperties;
2237 };
2238
2244 {
2245 public:
2246 UnsubscribePacket(Allocator *allocator = ApiAllocator()) noexcept;
2247
2248 /* The packet type */
2249 PacketType getType() override { return PacketType::AWS_MQTT5_PT_UNSUBSCRIBE; };
2250
2258 UnsubscribePacket &WithTopicFilter(Crt::String topicFilter) noexcept;
2259
2267 UnsubscribePacket &WithTopicFilters(Crt::Vector<String> topicFilters) noexcept;
2268
2278 UnsubscribePacket &WithUserProperties(const Vector<UserProperty> &userProperties) noexcept;
2279
2289 UnsubscribePacket &WithUserProperties(Vector<UserProperty> &&userProperties) noexcept;
2290
2300 UnsubscribePacket &WithUserProperty(UserProperty &&property) noexcept;
2301
2302 bool initializeRawOptions(aws_mqtt5_packet_unsubscribe_view &raw_options) noexcept;
2303
2304 virtual ~UnsubscribePacket();
2305 UnsubscribePacket(const UnsubscribePacket &) noexcept = delete;
2307 UnsubscribePacket &operator=(const UnsubscribePacket &) noexcept = delete;
2308 UnsubscribePacket &operator=(UnsubscribePacket &&) noexcept = delete;
2309
2310 private:
2311 Allocator *m_allocator;
2312
2319 Crt::Vector<String> m_topicFilters;
2320
2327 Crt::Vector<UserProperty> m_userProperties;
2328
2330 // Underlying data storage for internal use
2332 struct aws_array_list m_topicFiltersList;
2333 struct aws_mqtt5_user_property *m_userPropertiesStorage;
2334 };
2335
2341 {
2342 public:
2344 const aws_mqtt5_packet_unsuback_view &packet,
2345 Allocator *allocator = ApiAllocator()) noexcept;
2346
2347 /* The packet type */
2348 PacketType getType() override { return PacketType::AWS_MQTT5_PT_UNSUBACK; };
2349
2358 const Crt::Optional<Crt::String> &getReasonString() const noexcept;
2359
2368 const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
2369
2380 const Crt::Vector<UnSubAckReasonCode> &getReasonCodes() const noexcept;
2381
2382 virtual ~UnSubAckPacket() { m_userProperties.clear(); };
2383 UnSubAckPacket(const UnSubAckPacket &) noexcept = delete;
2384 UnSubAckPacket(UnSubAckPacket &&) noexcept = delete;
2385 UnSubAckPacket &operator=(const UnSubAckPacket &) noexcept = delete;
2386 UnSubAckPacket &operator=(UnSubAckPacket &&) noexcept = delete;
2387
2388 private:
2395 Crt::Optional<Crt::String> m_reasonString;
2396
2403 Crt::Vector<UserProperty> m_userProperties;
2404
2412 Crt::Vector<UnSubAckReasonCode> m_reasonCodes;
2413 };
2414
2415 } // namespace Mqtt5
2416 } // namespace Crt
2417} // namespace Aws
#define AWS_CRT_CPP_API
Definition Exports.h:36
Definition Mqtt5Packets.h:1180
ConnAckPacket(const ConnAckPacket &)=delete
ConnAckPacket(ConnAckPacket &&) noexcept=delete
PacketType getType() override
Definition Mqtt5Packets.h:1187
Definition Mqtt5Packets.h:672
PacketType getType() override
Definition Mqtt5Packets.h:678
Definition Mqtt5Packets.h:1560
PacketType getType() override
Definition Mqtt5Packets.h:1567
Definition Mqtt5Packets.h:42
virtual PacketType getType()=0
virtual ~IPacket()=default
Definition Mqtt5Packets.h:488
virtual ~NegotiatedSettings()
Definition Mqtt5Packets.h:589
NegotiatedSettings(NegotiatedSettings &&) noexcept=delete
NegotiatedSettings(const NegotiatedSettings &)=delete
Definition Mqtt5Packets.h:1776
PubAckPacket(const PubAckPacket &toCopy) noexcept=delete
PubAckPacket & operator=(PubAckPacket &&toMove) noexcept=delete
PubAckPacket & operator=(const PubAckPacket &toCopy) noexcept=delete
PubAckPacket(PubAckPacket &&toMove) noexcept=delete
PacketType getType() override
Definition Mqtt5Packets.h:1782
Definition Mqtt5Packets.h:53
PacketType getType() override
Definition Mqtt5Packets.h:64
Definition Mqtt5Packets.h:1853
std::shared_ptr< IPacket > getAck() const
Definition Mqtt5Packets.h:1879
bool wasSuccessful() const
Definition Mqtt5Packets.h:1864
int getErrorCode() const
Definition Mqtt5Packets.h:1871
Definition Mqtt5Packets.h:2165
PacketType getType() override
Definition Mqtt5Packets.h:2172
SubAckPacket(SubAckPacket &&) noexcept=delete
SubAckPacket(const SubAckPacket &) noexcept=delete
Definition Mqtt5Packets.h:2038
SubscribePacket(const SubscribePacket &) noexcept=delete
PacketType getType() override
Definition Mqtt5Packets.h:2043
SubscribePacket(SubscribePacket &&) noexcept=delete
Definition Mqtt5Packets.h:1899
virtual ~Subscription()
Definition Mqtt5Packets.h:1980
Definition Mqtt5Packets.h:2341
PacketType getType() override
Definition Mqtt5Packets.h:2348
UnSubAckPacket(UnSubAckPacket &&) noexcept=delete
UnSubAckPacket(const UnSubAckPacket &) noexcept=delete
Definition Mqtt5Packets.h:2244
UnsubscribePacket(const UnsubscribePacket &) noexcept=delete
PacketType getType() override
Definition Mqtt5Packets.h:2249
UnsubscribePacket(UnsubscribePacket &&) noexcept=delete
Definition Mqtt5Packets.h:23
const Crt::String & getName() const noexcept
Definition Mqtt5Packets.h:28
bool operator==(const UserProperty &other) const
Definition Mqtt5Packets.h:31
const Crt::String & getValue() const noexcept
Definition Mqtt5Packets.h:29
Definition Optional.h:19
aws_mqtt5_unsuback_reason_code UnSubAckReasonCode
Definition Mqtt5Types.h:169
aws_mqtt5_qos QOS
Definition Mqtt5Types.h:29
aws_mqtt5_connect_reason_code ConnectReasonCode
Definition Mqtt5Types.h:65
aws_mqtt5_suback_reason_code SubAckReasonCode
Definition Mqtt5Types.h:148
aws_mqtt5_retain_handling_type RetainHandlingType
Definition Mqtt5Types.h:278
aws_mqtt5_puback_reason_code PubAckReasonCode
Definition Mqtt5Types.h:127
aws_mqtt5_payload_format_indicator PayloadFormatIndicator
Definition Mqtt5Types.h:259
aws_mqtt5_disconnect_reason_code DisconnectReasonCode
Definition Mqtt5Types.h:107
aws_mqtt5_packet_type PacketType
Definition Mqtt5Types.h:308
aws_byte_cursor ByteCursor
Definition Types.h:31
aws_allocator Allocator
Definition Allocator.h:14
AWS_CRT_CPP_API Allocator * ApiAllocator() noexcept
Definition Allocator.cpp:24
std::basic_string< char, std::char_traits< char >, StlAllocator< char > > String
Definition Types.h:45
aws_byte_buf ByteBuf
Definition Types.h:30
std::vector< T, StlAllocator< T > > Vector
Definition Types.h:53
Definition Allocator.h:11
Definition StringView.h:862