1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
|
#pragma once
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/crt/mqtt/Mqtt5Client.h>
#include <aws/crt/mqtt/Mqtt5Packets.h>
#include <aws/crt/mqtt/Mqtt5Types.h>
namespace Aws
{
namespace Crt
{
namespace Mqtt5
{
/**
* Data model for MQTT5 user properties.
*
* A user property is a name-value pair of utf-8 strings that can be added to mqtt5 packets.
*/
class AWS_CRT_CPP_API UserProperty
{
public:
UserProperty(Crt::String key, Crt::String value) noexcept;
const Crt::String &getName() const noexcept { return m_name; };
const Crt::String &getValue() const noexcept { return m_value; }
~UserProperty() noexcept;
UserProperty(const UserProperty &toCopy) noexcept;
UserProperty(UserProperty &&toMove) noexcept;
UserProperty &operator=(const UserProperty &toCopy) noexcept;
UserProperty &operator=(UserProperty &&toMove) noexcept;
private:
Crt::String m_name;
Crt::String m_value;
};
class AWS_CRT_CPP_API IPacket
{
public:
virtual PacketType getType() = 0;
};
/**
* Data model of an [MQTT5
* PUBLISH](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901100) packet
*/
class AWS_CRT_CPP_API PublishPacket : public IPacket
{
public:
PublishPacket(
const aws_mqtt5_packet_publish_view &raw_options,
Allocator *allocator = ApiAllocator()) noexcept;
PublishPacket(Allocator *allocator = ApiAllocator()) noexcept;
PublishPacket(
Crt::String topic,
ByteCursor payload,
Mqtt5::QOS qos,
Allocator *allocator = ApiAllocator()) noexcept;
PacketType getType() override { return PacketType::AWS_MQTT5_PT_PUBLISH; };
/**
* Sets the payload for the publish message.
*
* See [MQTT5 Publish
* Payload](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901119)
*
* @param payload The payload for the publish message.
* @return The PublishPacket Object after setting the payload.
*/
PublishPacket &withPayload(ByteCursor payload) noexcept;
/**
* Sets the MQTT quality of service level the message should be delivered with.
*
* See [MQTT5 QoS](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901103)
*
* @param packetQOS The MQTT quality of service level the message should be delivered with.
* @return The PublishPacket Object after setting the QOS.
*/
PublishPacket &withQOS(Mqtt5::QOS packetQOS) noexcept;
/**
* Sets if this should be a retained message.
*
* See [MQTT5 Retain](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901104)
*
* @param retain if this is a retained message.
* @return The PublishPacket Object after setting the retain setting.
*/
PublishPacket &withRetain(bool retain) noexcept;
/**
* Sets the topic this message should be published to.
* See [MQTT5 Topic Name](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901107)
*
* @param topic The topic this message should be published to.
* @return The PublishPacket Object after setting the topic.
*/
PublishPacket &withTopic(Crt::String topic) noexcept;
/**
* Sets the property specifying the format of the payload data. The mqtt5 client does not enforce or use
* this value in a meaningful way.
*
* See [MQTT5 Payload Format
* Indicator](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901111)
*
* @param payloadFormat Property specifying the format of the payload data
* @return The PublishPacket Object after setting the payload format.
*/
PublishPacket &withPayloadFormatIndicator(PayloadFormatIndicator payloadFormat) noexcept;
/**
* Sets the maximum amount of time allowed to elapse for message delivery before the server
* should instead delete the message (relative to a recipient).
*
* See [MQTT5 Message Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901112)
*
* @param second The maximum amount of time allowed to elapse for message delivery
* before the server should instead delete the message (relative to a recipient).
* @return The PublishPacket Object after setting the message expiry interval.
*/
PublishPacket &withMessageExpiryIntervalSec(uint32_t second) noexcept;
/**
* Sets the opaque topic string intended to assist with request/response implementations. Not
* internally meaningful to MQTT5 or this client.
*
* See [MQTT5 Response
* Topic](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901114)
* @param responseTopic
* @return The PublishPacket Object after setting the response topic.
*/
PublishPacket &withResponseTopic(ByteCursor responseTopic) noexcept;
/**
* Sets the opaque binary data used to correlate between publish messages, as a potential method for
* request-response implementation. Not internally meaningful to MQTT5.
*
* See [MQTT5 Correlation
* Data](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901115)
*
* @param correlationData Opaque binary data used to correlate between publish messages
* @return The PublishPacket Object after setting the correlation data.
*/
PublishPacket &withCorrelationData(ByteCursor correlationData) noexcept;
/**
* Sets the list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*
* @param userProperties List of MQTT5 user properties included with the packet.
* @return The PublishPacket Object after setting the user properties
*/
PublishPacket &withUserProperties(const Vector<UserProperty> &userProperties) noexcept;
/**
* Sets the list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*
* @param userProperties List of MQTT5 user properties included with the packet.
* @return The PublishPacket Object after setting the user properties
*/
PublishPacket &withUserProperties(Vector<UserProperty> &&userProperties) noexcept;
/**
* Put a MQTT5 user property to the back of the packet user property vector/list
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*
* @param property set of userProperty of MQTT5 user properties included with the packet.
* @return The PublishPacket Object after setting the user property
*/
PublishPacket &withUserProperty(UserProperty &&property) noexcept;
bool initializeRawOptions(aws_mqtt5_packet_publish_view &raw_options) noexcept;
/**
* The payload of the publish message.
*
* See [MQTT5 Publish
* Payload](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901119)
*
* @return The payload of the publish message.
*/
const ByteCursor &getPayload() const noexcept;
/**
* Sent publishes - The MQTT quality of service level this message should be delivered with.
*
* Received publishes - The MQTT quality of service level this message was delivered at.
*
* See [MQTT5 QoS](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901103)
*
* @return The MQTT quality of service associated with this PUBLISH packet.
*/
Mqtt5::QOS getQOS() const noexcept;
/**
* True if this is a retained message, false otherwise.
*
* Always set on received publishes.
*
* See [MQTT5 Retain](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901104)
*
* @return True if this is a retained message, false otherwise.
*/
bool getRetain() const noexcept;
/**
* Sent publishes - The topic this message should be published to.
*
* Received publishes - The topic this message was published to.
*
* See [MQTT5 Topic Name](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901107)
* @return The topic associated with this PUBLISH packet.
*/
const Crt::String &getTopic() const noexcept;
/**
* Property specifying the format of the payload data. The mqtt5 client does not enforce or use this
* value in a meaningful way.
*
* See [MQTT5 Payload Format
* Indicator](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901111)
*
* @return Property specifying the format of the payload data.
*/
const Crt::Optional<PayloadFormatIndicator> &getPayloadFormatIndicator() const noexcept;
/**
* Sent publishes - indicates the maximum amount of time allowed to elapse for message delivery before
* the server should instead delete the message (relative to a recipient).
*
* Received publishes - indicates the remaining amount of time (from the server's perspective) before
* the message would have been deleted relative to the subscribing client.
*
* If left null, indicates no expiration timeout.
*
* See [MQTT5 Message Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901112)
*
* @return The message expiry interval associated with this PUBLISH packet.
*/
const Crt::Optional<uint32_t> &getMessageExpiryIntervalSec() const noexcept;
/**
* Opaque topic string intended to assist with request/response implementations. Not internally
* meaningful to MQTT5 or this client.
*
* See [MQTT5 Response
* Topic](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901114)
*
* @return ByteCursor to topic string intended to assist with request/response implementations.
*/
const Crt::Optional<ByteCursor> &getResponseTopic() const noexcept;
/**
* Opaque binary data used to correlate between publish messages, as a potential method for
* request-response implementation. Not internally meaningful to MQTT5.
*
* See [MQTT5 Correlation
* Data](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901115)
*
* @return ByteCursor to opaque binary data used to correlate between publish messages.
*/
const Crt::Optional<ByteCursor> &getCorrelationData() const noexcept;
/**
* Sent publishes - ignored
*
* Received publishes - the subscription identifiers of all the subscriptions this message matched.
*
* See [MQTT5 Subscription
* Identifier](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901117)
*
* @return the subscription identifiers of all the subscriptions this message matched.
*/
const Crt::Vector<uint32_t> &getSubscriptionIdentifiers() const noexcept;
/**
* Property specifying the content type of the payload. Not internally meaningful to MQTT5.
*
* See [MQTT5 Content Type](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901118)
*
* @return ByteCursor to opaque binary data to the content type of the payload.
*/
const Crt::Optional<ByteCursor> &getContentType() const noexcept;
/**
* List of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*
* @return List of MQTT5 user properties included with the packet.
*/
const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
virtual ~PublishPacket();
PublishPacket(const PublishPacket &) = delete;
PublishPacket(PublishPacket &&) noexcept = delete;
PublishPacket &operator=(const PublishPacket &) = delete;
PublishPacket &operator=(PublishPacket &&) noexcept = delete;
private:
Allocator *m_allocator;
/**
* The payload of the publish message.
*
* See [MQTT5 Publish
* Payload](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901119)
*/
ByteCursor m_payload;
/**
* Sent publishes - The MQTT quality of service level this message should be delivered with.
*
* Received publishes - The MQTT quality of service level this message was delivered at.
*
* See [MQTT5 QoS](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901103)
*/
Mqtt5::QOS m_qos;
/**
* True if this is a retained message, false otherwise.
*
* Always set on received publishes, default to false
*
* See [MQTT5 Retain](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901104)
*/
bool m_retain;
/**
* Sent publishes - The topic this message should be published to.
*
* Received publishes - The topic this message was published to.
*
* See [MQTT5 Topic Name](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901107)
*/
Crt::String m_topicName;
/**
* Property specifying the format of the payload data. The mqtt5 client does not enforce or use this
* value in a meaningful way.
*
* See [MQTT5 Payload Format
* Indicator](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901111)
*/
Crt::Optional<PayloadFormatIndicator> m_payloadFormatIndicator;
/**
* Sent publishes - indicates the maximum amount of time allowed to elapse for message delivery before
* the server should instead delete the message (relative to a recipient).
*
* Received publishes - indicates the remaining amount of time (from the server's perspective) before
* the message would have been deleted relative to the subscribing client.
*
* If left undefined, indicates no expiration timeout.
*
* See [MQTT5 Message Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901112)
*/
Crt::Optional<uint32_t> m_messageExpiryIntervalSec;
/**
* Opaque topic string intended to assist with request/response implementations. Not internally
* meaningful to MQTT5 or this client.
*
* See [MQTT5 Response
* Topic](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901114)
*/
Crt::Optional<ByteCursor> m_responseTopic;
/**
* Opaque binary data used to correlate between publish messages, as a potential method for
* request-response implementation. Not internally meaningful to MQTT5.
*
* See [MQTT5 Correlation
* Data](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901115)
*/
Crt::Optional<ByteCursor> m_correlationData;
/**
* Set of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*/
Crt::Vector<UserProperty> m_userProperties;
///////////////////////////////////////////////////////////////////////////
// The following parameters are ignored when building publish operations */
///////////////////////////////////////////////////////////////////////////
/**
* Sent publishes - ignored
*
* Received publishes - the subscription identifiers of all the subscriptions this message matched.
*
* See [MQTT5 Subscription
* Identifier](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901117)
*/
Crt::Vector<uint32_t> m_subscriptionIdentifiers;
/**
* Property specifying the content type of the payload. Not internally meaningful to MQTT5.
*
* See [MQTT5 Content Type](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901118)
*/
Crt::Optional<ByteCursor> m_contentType;
///////////////////////////////////////////////////////////////////////////
// Underlying data storage for internal use
///////////////////////////////////////////////////////////////////////////
ByteBuf m_payloadStorage;
ByteBuf m_contentTypeStorage;
ByteBuf m_correlationDataStorage;
Crt::String m_responseTopicString;
struct aws_mqtt5_user_property *m_userPropertiesStorage;
};
/**
* Mqtt behavior settings that are dynamically negotiated as part of the CONNECT/CONNACK exchange.
*
* While you can infer all of these values from a combination of
* (1) defaults as specified in the mqtt5 spec
* (2) your CONNECT settings
* (3) the CONNACK from the broker
*
* the client instead does the combining for you and emits a NegotiatedSettings object with final,
* authoritative values.
*
* Negotiated settings are communicated with every successful connection establishment.
*/
class AWS_CRT_CPP_API NegotiatedSettings
{
public:
NegotiatedSettings(
const aws_mqtt5_negotiated_settings &negotiated_settings,
Allocator *allocator = ApiAllocator()) noexcept;
/**
* @return The maximum QoS allowed for publishes on this connection instance
*/
Mqtt5::QOS getMaximumQOS() const noexcept;
/**
* @return The amount of time in seconds the server will retain the MQTT session after a disconnect.
*/
uint32_t getSessionExpiryIntervalSec() const noexcept;
/**
* @return The number of in-flight QoS 1 and QoS 2 publications the server is willing to process
* concurrently.
*/
uint16_t getReceiveMaximumFromServer() const noexcept;
/**
* @return The maximum packet size the server is willing to accept.
*/
uint32_t getMaximumPacketSizeBytes() const noexcept;
/**
* The maximum amount of time in seconds between client packets. The client should use PINGREQs to
* ensure this limit is not breached. The server will disconnect the client for inactivity if no MQTT
* packet is received in a time interval equal to 1.5 x this value.
*
* @return The maximum amount of time in seconds between client packets.
*/
uint16_t getServerKeepAlive() const noexcept;
/**
* @return Whether the server supports retained messages.
*/
bool getRetainAvailable() const noexcept;
/**
* @return Whether the server supports wildcard subscriptions.
*/
bool getWildcardSubscriptionsAvaliable() const noexcept;
/**
* @return Whether the server supports subscription identifiers
*/
bool getSubscriptionIdentifiersAvaliable() const noexcept;
/**
* @return Whether the server supports shared subscriptions
*/
bool getSharedSubscriptionsAvaliable() const noexcept;
/**
* @return Whether the client has rejoined an existing session.
*/
bool getRejoinedSession() const noexcept;
/**
* The final client id in use by the newly-established connection. This will be the configured client
* id if one was given in the configuration, otherwise, if no client id was specified, this will be the
* client id assigned by the server. Reconnection attempts will always use the auto-assigned client id,
* allowing for auto-assigned session resumption.
*
* @return The final client id in use by the newly-established connection
*/
const Crt::String &getClientId() const noexcept;
virtual ~NegotiatedSettings(){};
NegotiatedSettings(const NegotiatedSettings &) = delete;
NegotiatedSettings(NegotiatedSettings &&) noexcept = delete;
NegotiatedSettings &operator=(const NegotiatedSettings &) = delete;
NegotiatedSettings &operator=(NegotiatedSettings &&) noexcept = delete;
private:
/**
* The maximum QoS allowed for publishes on this connection instance
*/
Mqtt5::QOS m_maximumQOS;
/**
* The amount of time in seconds the server will retain the MQTT session after a disconnect.
*/
uint32_t m_sessionExpiryIntervalSec;
/**
* The number of in-flight QoS 1 and QoS2 publications the server is willing to process concurrently.
*/
uint16_t m_receiveMaximumFromServer;
/**
* The maximum packet size the server is willing to accept.
*/
uint32_t m_maximumPacketSizeBytes;
/**
* The maximum amount of time in seconds between client packets. The client should use PINGREQs to
* ensure this limit is not breached. The server will disconnect the client for inactivity if no MQTT
* packet is received in a time interval equal to 1.5 x this value.
*/
uint16_t m_serverKeepAliveSec;
/**
* Whether the server supports retained messages.
*/
bool m_retainAvailable;
/**
* Whether the server supports wildcard subscriptions.
*/
bool m_wildcardSubscriptionsAvaliable;
/**
* Whether the server supports subscription identifiers
*/
bool m_subscriptionIdentifiersAvaliable;
/**
* Whether the server supports shared subscriptions
*/
bool m_sharedSubscriptionsAvaliable;
/**
* Whether the client has rejoined an existing session.
*/
bool m_rejoinedSession;
/**
* The final client id in use by the newly-established connection. This will be the configured client
* id if one was given in the configuration, otherwise, if no client id was specified, this will be the
* client id assigned by the server. Reconnection attempts will always use the auto-assigned client id,
* allowing for auto-assigned session resumption.
*/
Crt::String m_clientId;
};
/**
* Data model of an [MQTT5
* CONNECT](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901033) packet.
*/
class AWS_CRT_CPP_API ConnectPacket : public IPacket
{
public:
/* Default constructor */
ConnectPacket(Allocator *allocator = ApiAllocator()) noexcept;
/* The packet type */
PacketType getType() override { return PacketType::AWS_MQTT5_PT_CONNECT; };
/**
* Sets the maximum time interval, in seconds, that is permitted to elapse between the point at which
* the client finishes transmitting one MQTT packet and the point it starts sending the next. The
* client will use PINGREQ packets to maintain this property.
*
* If the responding CONNACK contains a keep alive property value, then that is the negotiated keep
* alive value. Otherwise, the keep alive sent by the client is the negotiated value.
*
* See [MQTT5 Keep Alive](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901045)
*
* NOTE: The keepAliveIntervalSeconds HAS to be larger than the pingTimeoutMs time set in the
* Mqtt5ClientOptions.
*
* @param keepAliveInteralSeconds the maximum time interval, in seconds, that is permitted to elapse
* between the point at which the client finishes transmitting one MQTT packet and the point it starts
* sending the next.
* @return The ConnectPacket Object after setting the keep alive interval.
*/
ConnectPacket &withKeepAliveIntervalSec(uint16_t keepAliveInteralSeconds) noexcept;
/**
* Sets the unique string identifying the client to the server. Used to restore session state between
* connections.
*
* If left empty, the broker will auto-assign a unique client id. When reconnecting, the mqtt5 client
* will always use the auto-assigned client id.
*
* See [MQTT5 Client
* Identifier](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901059)
*
* @param clientId A unique string identifying the client to the server.
* @return The ConnectPacket Object after setting the client ID.
*/
ConnectPacket &withClientId(Crt::String clientId) noexcept;
/**
* Sets the string value that the server may use for client authentication and authorization.
*
* See [MQTT5 User Name](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901071)
*
* @param username The string value that the server may use for client authentication and authorization.
* @return The ConnectPacket Object after setting the username.
*/
ConnectPacket &withUserName(Crt::String username) noexcept;
/**
* Sets the opaque binary data that the server may use for client authentication and authorization.
*
* See [MQTT5 Password](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901072)
*
* @param password Opaque binary data that the server may use for client authentication and
* authorization.
* @return The ConnectPacket Object after setting the password.
*/
ConnectPacket &withPassword(ByteCursor password) noexcept;
/**
* Sets the time interval, in seconds, that the client requests the server to persist this connection's
* MQTT session state for. Has no meaning if the client has not been configured to rejoin sessions.
* Must be non-zero in order to successfully rejoin a session.
*
* If the responding CONNACK contains a session expiry property value, then that is the negotiated
* session expiry value. Otherwise, the session expiry sent by the client is the negotiated value.
*
* See [MQTT5 Session Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901048)
*
* @param sessionExpiryIntervalSeconds A time interval, in seconds, that the client requests the server
* to persist this connection's MQTT session state for.
* @return The ConnectPacket Object after setting the session expiry interval.
*/
ConnectPacket &withSessionExpiryIntervalSec(uint32_t sessionExpiryIntervalSeconds) noexcept;
/**
* Sets whether requests that the server send response information in the subsequent CONNACK. This
* response information may be used to set up request-response implementations over MQTT, but doing so
* is outside the scope of the MQTT5 spec and client.
*
* See [MQTT5 Request Response
* Information](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901052)
*
* @param requestResponseInformation If true, requests that the server send response information in the
* subsequent CONNACK.
* @return The ConnectPacket Object after setting the request response information.
*/
ConnectPacket &withRequestResponseInformation(bool requestResponseInformation) noexcept;
/**
* Sets whether requests that the server send additional diagnostic information (via response string or
* user properties) in DISCONNECT or CONNACK packets from the server.
*
* See [MQTT5 Request Problem
* Information](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901053)
*
* @param requestProblemInformation If true, requests that the server send additional diagnostic
* information (via response string or user properties) in DISCONNECT or CONNACK packets from the
* server.
* @return The ConnectPacket Object after setting the request problem information.
*/
ConnectPacket &withRequestProblemInformation(bool requestProblemInformation) noexcept;
/**
* Sets the maximum number of in-flight QoS 1 and 2 messages the client is willing to handle. If
* omitted, then no limit is requested.
*
* See [MQTT5 Receive
* Maximum](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901049)
*
* @param receiveMaximum The maximum number of in-flight QoS 1 and 2 messages the client is willing to
* handle.
* @return The ConnectPacket Object after setting the receive maximum.
*/
ConnectPacket &withReceiveMaximum(uint16_t receiveMaximum) noexcept;
/**
* Sets the maximum packet size the client is willing to handle. If
* omitted, then no limit beyond the natural limits of MQTT packet size is requested.
*
* See [MQTT5 Maximum Packet
* Size](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901050)
*
* @param maximumPacketSizeBytes The maximum packet size the client is willing to handle
* @return The ConnectPacket Object after setting the maximum packet size.
*/
ConnectPacket &withMaximumPacketSizeBytes(uint32_t maximumPacketSizeBytes) noexcept;
/**
* Sets the time interval, in seconds, that the server should wait (for a session reconnection) before
* sending the will message associated with the connection's session. If omitted, the server
* will send the will when the associated session is destroyed. If the session is destroyed before a
* will delay interval has elapsed, then the will must be sent at the time of session destruction.
*
* See [MQTT5 Will Delay
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901062)
*
* @param willDelayIntervalSeconds A time interval, in seconds, that the server should wait (for a
* session reconnection) before sending the will message associated with the connection's session.
* @return The ConnectPacket Object after setting the will message delay interval.
*/
ConnectPacket &withWillDelayIntervalSec(uint32_t willDelayIntervalSeconds) noexcept;
/**
* Sets the definition of a message to be published when the connection's session is destroyed by the
* server or when the will delay interval has elapsed, whichever comes first. If null, then nothing
* will be sent.
*
* See [MQTT5 Will](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901040)
*
* @param will The message to be published when the connection's session is destroyed by the server or
* when the will delay interval has elapsed, whichever comes first.
* @return The ConnectPacket Object after setting the will message.
*/
ConnectPacket &withWill(std::shared_ptr<PublishPacket> will) noexcept;
/**
* Sets the list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901054)
*
* @param userProperties List of MQTT5 user properties included with the packet.
* @return The ConnectPacket Object after setting the user properties.
*/
ConnectPacket &withUserProperties(const Vector<UserProperty> &userProperties) noexcept;
/**
* Sets the list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901054)
*
* @param userProperties List of MQTT5 user properties included with the packet.
* @return The ConnectPacket Object after setting the user properties.
*/
ConnectPacket &withUserProperties(Vector<UserProperty> &&userProperties) noexcept;
/**
* Put a MQTT5 user property to the back of the packet user property vector/list
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*
* @param property set of userProperty of MQTT5 user properties included with the packet.
* @return The ConnectPacket Object after setting the user property
*/
ConnectPacket &withUserProperty(UserProperty &&property) noexcept;
/********************************************
* Access Functions
********************************************/
/**
* The maximum time interval, in seconds, that is permitted to elapse between the point at which the
* client finishes transmitting one MQTT packet and the point it starts sending the next. The client
* will use PINGREQ packets to maintain this property.
*
* If the responding CONNACK contains a keep alive property value, then that is the negotiated keep
* alive value. Otherwise, the keep alive sent by the client is the negotiated value.
*
* See [MQTT5 Keep Alive](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901045)
*
* @return The maximum time interval, in seconds, that is permitted to elapse between the point at which
* the client finishes transmitting one MQTT packet and the point it starts sending the next.
*/
uint16_t getKeepAliveIntervalSec() const noexcept;
/**
* A unique string identifying the client to the server. Used to restore session state between
* connections.
*
* If left empty, the broker will auto-assign a unique client id. When reconnecting, the mqtt5 client
* will always use the auto-assigned client id.
*
* See [MQTT5 Client
* Identifier](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901059)
*
* @return A unique string identifying the client to the server.
*/
const Crt::String &getClientId() const noexcept;
/**
* A string value that the server may use for client authentication and authorization.
*
* See [MQTT5 User Name](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901071)
*
* @return A string value that the server may use for client authentication and authorization.
*/
const Crt::Optional<Crt::String> &getUsername() const noexcept;
/**
* Opaque binary data that the server may use for client authentication and authorization.
*
* See [MQTT5 Password](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901072)
*
* @return Opaque binary data that the server may use for client authentication and authorization.
*/
const Crt::Optional<Crt::ByteCursor> &getPassword() const noexcept;
/**
* A time interval, in seconds, that the client requests the server to persist this connection's MQTT
* session state for. Has no meaning if the client has not been configured to rejoin sessions. Must be
* non-zero in order to successfully rejoin a session.
*
* If the responding CONNACK contains a session expiry property value, then that is the negotiated
* session expiry value. Otherwise, the session expiry sent by the client is the negotiated value.
*
* See [MQTT5 Session Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901048)
*
* @return A time interval, in seconds, that the client requests the server to persist this connection's
* MQTT session state for.
*/
const Crt::Optional<uint32_t> &getSessionExpiryIntervalSec() const noexcept;
/**
* If true, requests that the server send response information in the subsequent CONNACK. This response
* information may be used to set up request-response implementations over MQTT, but doing so is outside
* the scope of the MQTT5 spec and client.
*
* See [MQTT5 Request Response
* Information](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901052)
*
* @return If true, requests that the server send response information in the subsequent CONNACK.
*/
const Crt::Optional<bool> &getRequestResponseInformation() const noexcept;
/**
* If true, requests that the server send additional diagnostic information (via response string or
* user properties) in DISCONNECT or CONNACK packets from the server.
*
* See [MQTT5 Request Problem
* Information](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901053)
*
* @return If true, requests that the server send additional diagnostic information (via response string
* or user properties) in DISCONNECT or CONNACK packets from the server.
*/
const Crt::Optional<bool> &getRequestProblemInformation() const noexcept;
/**
* Notifies the server of the maximum number of in-flight QoS 1 and 2 messages the client is willing to
* handle. If omitted or null, then no limit is requested.
*
* See [MQTT5 Receive
* Maximum](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901049)
*
* @return The maximum number of in-flight QoS 1 and 2 messages the client is willing to handle.
*/
const Crt::Optional<uint16_t> &getReceiveMaximum() const noexcept;
/**
* Notifies the server of the maximum packet size the client is willing to handle. If
* omitted or null, then no limit beyond the natural limits of MQTT packet size is requested.
*
* See [MQTT5 Maximum Packet
* Size](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901050)
*
* @return The maximum packet size the client is willing to handle
*/
const Crt::Optional<uint32_t> &getMaximumPacketSizeBytes() const noexcept;
/**
* A time interval, in seconds, that the server should wait (for a session reconnection) before sending
* the will message associated with the connection's session. If omitted or null, the server will send
* the will when the associated session is destroyed. If the session is destroyed before a will delay
* interval has elapsed, then the will must be sent at the time of session destruction.
*
* See [MQTT5 Will Delay
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901062)
*
* @return A time interval, in seconds, that the server should wait (for a session reconnection) before
* sending the will message associated with the connection's session.
*/
const Crt::Optional<uint32_t> &getWillDelayIntervalSec() const noexcept;
/**
* The definition of a message to be published when the connection's session is destroyed by the server
* or when the will delay interval has elapsed, whichever comes first. If null, then nothing will be
* sent.
*
* See [MQTT5 Will](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901040)
*
* @return The message to be published when the connection's session is destroyed by the server or when
* the will delay interval has elapsed, whichever comes first.
*/
const Crt::Optional<std::shared_ptr<PublishPacket>> &getWill() const noexcept;
/**
* List of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901054)
*
* @return List of MQTT5 user properties included with the packet.
*/
const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
/**
* Intended for internal use only. Initializes the C aws_mqtt5_packet_connack_view
* from PacketConnect
*
* @param raw_options - output parameter containing low level client options to be passed to the C
* @param allocator - memory Allocator
*
*/
bool initializeRawOptions(aws_mqtt5_packet_connect_view &raw_options, Allocator *allocator) noexcept;
virtual ~ConnectPacket();
ConnectPacket(const ConnectPacket &) = delete;
ConnectPacket(ConnectPacket &&) noexcept = delete;
ConnectPacket &operator=(const ConnectPacket &) = delete;
ConnectPacket &operator=(ConnectPacket &&) noexcept = delete;
private:
Allocator *m_allocator;
/**
* The maximum time interval, in seconds, that is permitted to elapse between the point at which the
* client finishes transmitting one MQTT packet and the point it starts sending the next. The client
* will use PINGREQ packets to maintain this property.
*
* If the responding CONNACK contains a keep alive property value, then that is the negotiated keep
* alive value. Otherwise, the keep alive sent by the client is the negotiated value.
*
* See [MQTT5 Keep Alive](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901045)
*/
uint16_t m_keepAliveIntervalSec;
/**
* A unique string identifying the client to the server. Used to restore session state between
* connections.
*
* If left empty, the broker will auto-assign a unique client id. When reconnecting, the mqtt5 client
* will always use the auto-assigned client id.
*
* See [MQTT5 Client
* Identifier](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901059)
*/
Crt::String m_clientId;
/**
* A string value that the server may use for client authentication and authorization.
*
* See [MQTT5 User Name](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901071)
*/
Crt::Optional<Crt::String> m_username;
/**
* Opaque binary data that the server may use for client authentication and authorization.
*
* See [MQTT5 Password](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901072)
*/
Crt::Optional<ByteCursor> m_password;
/**
* A time interval, in seconds, that the client requests the server to persist this connection's MQTT
* session state for. Has no meaning if the client has not been configured to rejoin sessions. Must be
* non-zero in order to successfully rejoin a session.
*
* If the responding CONNACK contains a session expiry property value, then that is the negotiated
* session expiry value. Otherwise, the session expiry sent by the client is the negotiated value.
*
* See [MQTT5 Session Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901048)
*/
Crt::Optional<uint32_t> m_sessionExpiryIntervalSec;
/**
* If set to true, requests that the server send response information in the subsequent CONNACK. This
* response information may be used to set up request-response implementations over MQTT, but doing so
* is outside the scope of the MQTT5 spec and client.
*
* See [MQTT5 Request Response
* Information](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901052)
*/
Crt::Optional<bool> m_requestResponseInformation;
/**
* If set to true, requests that the server send additional diagnostic information (via response string
* or user properties) in DISCONNECT or CONNACK packets from the server.
*
* See [MQTT5 Request Problem
* Information](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901053)
*/
Crt::Optional<bool> m_requestProblemInformation;
/**
* Notifies the server of the maximum number of in-flight Qos 1 and 2 messages the client is willing to
* handle. If omitted, then no limit is requested.
*
* See [MQTT5 Receive
* Maximum](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901049)
*/
Crt::Optional<uint16_t> m_receiveMaximum;
/**
* Notifies the server of the maximum packet size the client is willing to handle. If
* omitted, then no limit beyond the natural limits of MQTT packet size is requested.
*
* See [MQTT5 Maximum Packet
* Size](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901050)
*/
Crt::Optional<uint32_t> m_maximumPacketSizeBytes;
/**
* A time interval, in seconds, that the server should wait (for a session reconnection) before sending
* the will message associated with the connection's session. If omitted, the server will send the will
* when the associated session is destroyed. If the session is destroyed before a will delay interval
* has elapsed, then the will must be sent at the time of session destruction.
*
* See [MQTT5 Will Delay
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901062)
*/
Crt::Optional<uint32_t> m_willDelayIntervalSeconds;
/**
* The definition of a message to be published when the connection's session is destroyed by the server
* or when the will delay interval has elapsed, whichever comes first. If undefined, then nothing will
* be sent.
*
* See [MQTT5 Will](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901040)
*/
Crt::Optional<std::shared_ptr<PublishPacket>> m_will;
/**
* Set of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901054)
*/
Crt::Vector<UserProperty> m_userProperties;
///////////////////////////////////////////////////////////////////////////
// Underlying data storage for internal use
///////////////////////////////////////////////////////////////////////////
struct aws_byte_cursor m_usernameCursor;
struct aws_byte_buf m_passowrdStorage;
struct aws_mqtt5_packet_publish_view m_willStorage;
struct aws_mqtt5_user_property *m_userPropertiesStorage;
uint8_t m_requestResponseInformationStorage;
uint8_t m_requestProblemInformationStorage;
};
/**
* Data model of an [MQTT5
* CONNACK](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901074) packet.
*/
class AWS_CRT_CPP_API ConnAckPacket : public IPacket
{
public:
ConnAckPacket(
const aws_mqtt5_packet_connack_view &packet,
Allocator *allocator = ApiAllocator()) noexcept;
/* The packet type */
PacketType getType() override { return PacketType::AWS_MQTT5_PT_CONNACK; };
/**
* True if the client rejoined an existing session on the server, false otherwise.
*
* See [MQTT5 Session
* Present](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901078)
*
* @return True if the client rejoined an existing session on the server, false otherwise.
*/
bool getSessionPresent() const noexcept;
/**
* Indicates either success or the reason for failure for the connection attempt.
*
* See [MQTT5 Connect Reason
* Code](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901079)
*
* @return Code indicating either success or the reason for failure for the connection attempt.
*/
ConnectReasonCode getReasonCode() const noexcept;
/**
* A time interval, in seconds, that the server will persist this connection's MQTT session state
* for. If present, this value overrides any session expiry specified in the preceding CONNECT packet.
*
* See [MQTT5 Session Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901082)
*
* @return A time interval, in seconds, that the server will persist this connection's MQTT session
* state for.
*/
const Crt::Optional<uint32_t> &getSessionExpiryInterval() const noexcept;
/**
* The maximum amount of in-flight QoS 1 or 2 messages that the server is willing to handle at once. If
* omitted or null, the limit is based on the valid MQTT packet id space (65535).
*
* See [MQTT5 Receive
* Maximum](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901083)
*
* @return The maximum amount of in-flight QoS 1 or 2 messages that the server is willing to handle at
* once.
*/
const Crt::Optional<uint16_t> &getReceiveMaximum() const noexcept;
/**
* The maximum message delivery quality of service that the server will allow on this connection.
*
* See [MQTT5 Maximum QoS](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901084)
*
* @return The maximum message delivery quality of service that the server will allow on this
* connection.
*/
const Crt::Optional<QOS> &getMaximumQOS() const noexcept;
/**
* Indicates whether the server supports retained messages. If null, retained messages are
* supported.
*
* See [MQTT5 Retain
* Available](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901085)
*
* @return Whether the server supports retained messages
*/
const Crt::Optional<bool> &getRetainAvailable() const noexcept;
/**
* Specifies the maximum packet size, in bytes, that the server is willing to accept. If null, there
* is no limit beyond what is imposed by the MQTT spec itself.
*
* See [MQTT5 Maximum Packet
* Size](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901086)
*
* @return The maximum packet size, in bytes, that the server is willing to accept.
*/
const Crt::Optional<uint32_t> &getMaximumPacketSize() const noexcept;
/**
* Specifies a client identifier assigned to this connection by the server. Only valid when the client
* id of the preceding CONNECT packet was left empty.
*
* See [MQTT5 Assigned Client
* Identifier](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901087)
*
* @return Client identifier assigned to this connection by the server
*/
const Crt::Optional<String> &getAssignedClientIdentifier() const noexcept;
/**
* Specifies the maximum topic alias value that the server will accept from the client.
*
* See [MQTT5 Topic Alias
* Maximum](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901088)
*
* @return maximum topic alias
*/
const Crt::Optional<uint16_t> getTopicAliasMaximum() const noexcept;
/**
* Additional diagnostic information about the result of the connection attempt.
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901089)
*
* @return Additional diagnostic information about the result of the connection attempt.
*/
const Crt::Optional<String> &getReasonString() const noexcept;
/**
* List of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901090)
*
* @return List of MQTT5 user properties included with the packet.
*/
const Vector<UserProperty> &getUserProperty() const noexcept;
/**
* Indicates whether the server supports wildcard subscriptions. If null, wildcard subscriptions
* are supported.
*
* See [MQTT5 Wildcard Subscriptions
* Available](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901091)
*
* @return Whether the server supports wildcard subscriptions.
*/
const Crt::Optional<bool> &getWildcardSubscriptionsAvaliable() const noexcept;
/**
* Indicates whether the server supports subscription identifiers. If null, subscription identifiers
* are supported.
*
* See [MQTT5 Subscription Identifiers
* Available](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901092)
*
* @return whether the server supports subscription identifiers.
*/
const Crt::Optional<bool> &getSubscriptionIdentifiersAvaliable() const noexcept;
/**
* Indicates whether the server supports shared subscription topic filters. If null, shared
* subscriptions are supported.
*
* See [MQTT5 Shared Subscriptions
* Available](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901093)
*
* @return whether the server supports shared subscription topic filters.
*/
const Crt::Optional<bool> &getSharedSubscriptionsAvaliable() const noexcept;
/**
* Server-requested override of the keep alive interval, in seconds. If null, the keep alive value sent
* by the client should be used.
*
* See [MQTT5 Server Keep
* Alive](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901094)
*
* @return Server-requested override of the keep alive interval, in seconds
*/
const Crt::Optional<uint16_t> &getServerKeepAlive() const noexcept;
/**
* A value that can be used in the creation of a response topic associated with this connection.
* MQTT5-based request/response is outside the purview of the MQTT5 spec and this client.
*
* See [MQTT5 Response
* Information](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901095)
*
* @return A value that can be used in the creation of a response topic associated with this connection.
*/
const Crt::Optional<String> &getResponseInformation() const noexcept;
/**
* Property indicating an alternate server that the client may temporarily or permanently attempt
* to connect to instead of the configured endpoint. Will only be set if the reason code indicates
* another server may be used (ServerMoved, UseAnotherServer).
*
* See [MQTT5 Server
* Reference](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901096)
*
* @return Property indicating an alternate server that the client may temporarily or permanently
* attempt to connect to instead of the configured endpoint.
*/
const Crt::Optional<String> &getServerReference() const noexcept;
virtual ~ConnAckPacket(){};
ConnAckPacket(const ConnAckPacket &) = delete;
ConnAckPacket(ConnAckPacket &&) noexcept = delete;
ConnAckPacket &operator=(const ConnAckPacket &) = delete;
ConnAckPacket &operator=(ConnAckPacket &&) noexcept = delete;
private:
/**
* True if the client rejoined an existing session on the server, false otherwise.
*
* See [MQTT5 Session
* Present](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901078)
*/
bool m_sessionPresent;
/**
* Indicates either success or the reason for failure for the connection attempt.
*
* See [MQTT5 Connect Reason
* Code](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901079)
*/
ConnectReasonCode m_reasonCode;
/**
* A time interval, in seconds, that the server will persist this connection's MQTT session state
* for. If present, this value overrides any session expiry specified in the preceding CONNECT packet.
*
* See [MQTT5 Session Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901082)
*/
Crt::Optional<uint32_t> m_sessionExpiryInterval;
/**
* The maximum amount of in-flight QoS 1 or 2 messages that the server is willing to handle at once. If
* omitted, the limit is based on the valid MQTT packet id space (65535).
*
* See [MQTT5 Receive
* Maximum](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901083)
*/
Crt::Optional<uint16_t> m_receiveMaximum;
/**
* The maximum message delivery quality of service that the server will allow on this connection.
*
* See [MQTT5 Maximum QoS](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901084)
*/
Crt::Optional<QOS> m_maximumQOS;
/**
* Indicates whether the server supports retained messages. If undefined, retained messages are
* supported.
*
* See [MQTT5 Retain
* Available](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901085)
*/
Crt::Optional<bool> m_retainAvailable;
/**
* Specifies the maximum packet size, in bytes, that the server is willing to accept. If undefined,
* there is no limit beyond what is imposed by the MQTT spec itself.
*
* See [MQTT5 Maximum Packet
* Size](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901086)
*/
Crt::Optional<uint32_t> m_maximumPacketSize;
/**
* Specifies a client identifier assigned to this connection by the server. Only valid when the client
* id of the preceding CONNECT packet was left empty.
*
* See [MQTT5 Assigned Client
* Identifier](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901087)
*/
Crt::Optional<String> m_assignedClientIdentifier;
/**
* Specifies the maximum topic alias value that the server will accept from the client.
*
* See [MQTT5 Topic Alias
* Maximum](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901088)
*/
Crt::Optional<uint16_t> m_topicAliasMaximum;
/**
* Additional diagnostic information about the result of the connection attempt.
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901089)
*/
Crt::Optional<String> m_reasonString;
/**
* Indicates whether the server supports wildcard subscriptions. If undefined, wildcard subscriptions
* are supported.
*
* See [MQTT5 Wildcard Subscriptions
* Available](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901091)
*/
Crt::Optional<bool> m_wildcardSubscriptionsAvaliable;
/**
* Indicates whether the server supports subscription identifiers. If undefined, subscription
* identifiers are supported.
*
* See [MQTT5 Subscription Identifiers
* Available](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901092)
*/
Crt::Optional<bool> m_subscriptionIdentifiersAvaliable;
/**
* Indicates whether the server supports shared subscription topic filters. If undefined, shared
* subscriptions are supported.
*
* See [MQTT5 Shared Subscriptions
* Available](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901093)
*/
Crt::Optional<bool> m_sharedSubscriptionsAvaliable;
/**
* Server-requested override of the keep alive interval, in seconds. If undefined, the keep alive value
* sent by the client should be used.
*
* See [MQTT5 Server Keep
* Alive](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901094)
*/
Crt::Optional<uint16_t> m_serverKeepAlive;
/**
* A value that can be used in the creation of a response topic associated with this connection.
* MQTT5-based request/response is outside the purview of the MQTT5 spec and this client.
*
* See [MQTT5 Response
* Information](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901095)
*/
Crt::Optional<String> m_responseInformation;
/**
* Property indicating an alternate server that the client may temporarily or permanently attempt
* to connect to instead of the configured endpoint. Will only be set if the reason code indicates
* another server may be used (ServerMoved, UseAnotherServer).
*
* See [MQTT5 Server
* Reference](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901096)
*/
Crt::Optional<String> m_serverReference;
/**
* Set of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901090)
*/
Vector<UserProperty> m_userProperties;
};
/**
* Data model of an [MQTT5
* DISCONNECT](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901205) packet.
*/
class AWS_CRT_CPP_API DisconnectPacket : public IPacket
{
public:
DisconnectPacket(Allocator *allocator = ApiAllocator()) noexcept;
DisconnectPacket(
const aws_mqtt5_packet_disconnect_view &raw_options,
Allocator *allocator = ApiAllocator()) noexcept;
/* The packet type */
PacketType getType() override { return PacketType::AWS_MQTT5_PT_DISCONNECT; };
bool initializeRawOptions(aws_mqtt5_packet_disconnect_view &raw_options) noexcept;
/**
* Sets the value indicating the reason that the sender is closing the connection
*
* See [MQTT5 Disconnect Reason
* Code](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901208)
*
* @param reasonCode Value indicating the reason that the sender is closing the connection
* @return The DisconnectPacket Object after setting the reason code.
*/
DisconnectPacket &withReasonCode(const DisconnectReasonCode reasonCode) noexcept;
/**
* Sets the change to the session expiry interval negotiated at connection time as part of the
* disconnect. Only valid for DISCONNECT packets sent from client to server. It is not valid to
* attempt to change session expiry from zero to a non-zero value.
*
* See [MQTT5 Session Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901211)
*
* @param sessionExpiryIntervalSeconds
* @return The DisconnectPacket Object after setting the session expiry interval.
*/
DisconnectPacket &withSessionExpiryIntervalSec(const uint32_t sessionExpiryIntervalSeconds) noexcept;
/**
* Sets the additional diagnostic information about the reason that the sender is closing the connection
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901212)
*
* @param reasonString Additional diagnostic information about the reason that the sender is closing the
* connection
* @return The DisconnectPacket Object after setting the reason string.
*/
DisconnectPacket &withReasonString(Crt::String reasonString) noexcept;
/**
* Sets the property indicating an alternate server that the client may temporarily or permanently
* attempt to connect to instead of the configured endpoint. Will only be set if the reason code
* indicates another server may be used (ServerMoved, UseAnotherServer).
*
* See [MQTT5 Server
* Reference](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901214)
*
* @param serverReference Property indicating an alternate server that the client may temporarily or
* permanently attempt to connect to instead of the configured endpoint.
* @return The DisconnectPacket Object after setting the server reference.
*/
DisconnectPacket &withServerReference(Crt::String serverReference) noexcept;
/**
* Sets the list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901213)
*
* @param userProperties List of MQTT5 user properties included with the packet.
* @return The DisconnectPacket Object after setting the user properties.
*/
DisconnectPacket &withUserProperties(const Vector<UserProperty> &userProperties) noexcept;
/**
* Sets the list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901213)
*
* @param userProperties List of MQTT5 user properties included with the packet.
* @return The DisconnectPacket Object after setting the user properties.
*/
DisconnectPacket &withUserProperties(Vector<UserProperty> &&userProperties) noexcept;
/**
* Put a MQTT5 user property to the back of the packet user property vector/list
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*
* @param property set of userProperty of MQTT5 user properties included with the packet.
* @return The ConnectPacket Object after setting the user property
*/
DisconnectPacket &withUserProperty(UserProperty &&property) noexcept;
/**
* Value indicating the reason that the sender is closing the connection
*
* See [MQTT5 Disconnect Reason
* Code](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901208)
*
* @return Value indicating the reason that the sender is closing the connection
*/
DisconnectReasonCode getReasonCode() const noexcept;
/**
* A change to the session expiry interval negotiated at connection time as part of the disconnect. Only
* valid for DISCONNECT packets sent from client to server. It is not valid to attempt to change
* session expiry from zero to a non-zero value.
*
* See [MQTT5 Session Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901211)
*
* @return A change to the session expiry interval negotiated at connection time as part of the
* disconnect.
*/
const Crt::Optional<uint32_t> &getSessionExpiryIntervalSec() const noexcept;
/**
* Additional diagnostic information about the reason that the sender is closing the connection
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901212)
*
* @return Additional diagnostic information about the reason that the sender is closing the connection
*/
const Crt::Optional<Crt::String> &getReasonString() const noexcept;
/**
* Property indicating an alternate server that the client may temporarily or permanently attempt
* to connect to instead of the configured endpoint. Will only be set if the reason code indicates
* another server may be used (ServerMoved, UseAnotherServer).
*
* See [MQTT5 Server
* Reference](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901214)
*
* @return Property indicating an alternate server that the client may temporarily or permanently
* attempt to connect to instead of the configured endpoint.
*/
const Crt::Optional<Crt::String> &getServerReference() const noexcept;
/**
* List of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901213)
*
* @return List of MQTT5 user properties included with the packet.
*/
const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
virtual ~DisconnectPacket();
DisconnectPacket(const DisconnectPacket &) = delete;
DisconnectPacket(DisconnectPacket &&) noexcept = delete;
DisconnectPacket &operator=(const DisconnectPacket &) = delete;
DisconnectPacket &operator=(DisconnectPacket &&) noexcept = delete;
private:
Crt::Allocator *m_allocator;
/**
* Value indicating the reason that the sender is closing the connection
*
* See [MQTT5 Disconnect Reason
* Code](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901208)
*/
DisconnectReasonCode m_reasonCode;
/**
* Requests a change to the session expiry interval negotiated at connection time as part of the
* disconnect. Only valid for DISCONNECT packets sent from client to server. It is not valid to
* attempt to change session expiry from zero to a non-zero value.
*
* See [MQTT5 Session Expiry
* Interval](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901211)
*/
Crt::Optional<uint32_t> m_sessionExpiryIntervalSec;
/**
* Additional diagnostic information about the reason that the sender is closing the connection
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901212)
*/
Crt::Optional<Crt::String> m_reasonString;
/**
* Property indicating an alternate server that the client may temporarily or permanently attempt
* to connect to instead of the configured endpoint. Will only be set if the reason code indicates
* another server may be used (ServerMoved, UseAnotherServer).
*
* See [MQTT5 Server
* Reference](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901214)
*/
Crt::Optional<Crt::String> m_serverReference;
/**
* Set of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901213)
*/
Crt::Vector<UserProperty> m_userProperties;
///////////////////////////////////////////////////////////////////////////
// Underlying data storage for internal use
///////////////////////////////////////////////////////////////////////////
struct aws_byte_cursor m_reasonStringCursor;
struct aws_byte_cursor m_serverReferenceCursor;
struct aws_mqtt5_user_property *m_userPropertiesStorage;
};
/**
* Data model of an [MQTT5
* PUBACK](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901121) packet
*/
class AWS_CRT_CPP_API PubAckPacket : public IPacket
{
public:
PubAckPacket(
const aws_mqtt5_packet_puback_view &packet,
Allocator *allocator = ApiAllocator()) noexcept;
PacketType getType() override { return PacketType::AWS_MQTT5_PT_PUBACK; };
/**
* Success indicator or failure reason for the associated PUBLISH packet.
*
* See [MQTT5 PUBACK Reason
* Code](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901124)
*
* @return Success indicator or failure reason for the associated PUBLISH packet.
*/
PubAckReasonCode getReasonCode() const noexcept;
/**
* Additional diagnostic information about the result of the PUBLISH attempt.
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901127)
*
* @return Additional diagnostic information about the result of the PUBLISH attempt.
*/
const Crt::Optional<Crt::String> &getReasonString() const noexcept;
/**
* List of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901128)
*
* @return List of MQTT5 user properties included with the packet.
*/
const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
virtual ~PubAckPacket(){};
PubAckPacket(const PubAckPacket &toCopy) noexcept = delete;
PubAckPacket(PubAckPacket &&toMove) noexcept = delete;
PubAckPacket &operator=(const PubAckPacket &toCopy) noexcept = delete;
PubAckPacket &operator=(PubAckPacket &&toMove) noexcept = delete;
private:
/**
* Success indicator or failure reason for the associated PUBLISH packet.
*
* See [MQTT5 PUBACK Reason
* Code](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901124)
*/
PubAckReasonCode m_reasonCode;
/**
* Additional diagnostic information about the result of the PUBLISH attempt.
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901127)
*/
Crt::Optional<Crt::String> m_reasonString;
/**
* Set of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901128)
*/
Crt::Vector<UserProperty> m_userProperties;
};
/**
* PublishResult returned with onPublishCompletionCallback after Publish get called
*
* Publish with QoS0: Ack will be nullptr
* QoS1: Ack will contains a PubAckPacket
*/
class AWS_CRT_CPP_API PublishResult
{
public:
PublishResult(); // QoS 0 success
PublishResult(std::shared_ptr<PubAckPacket> puback); // Qos 1 success
PublishResult(int errorCode); // any failure
/**
* Get if the publish succeed or not
*
* @return true if error code == 0 and publish succeed
*/
bool wasSuccessful() const { return m_errorCode == 0; };
/**
* Get the error code value
*
* @return the error code
*/
int getErrorCode() const { return m_errorCode; };
/**
* Get Publish ack packet
*
* @return std::shared_ptr<IPacket> contains a PubAckPacket if client Publish with QoS1, otherwise
* nullptr.
*/
std::shared_ptr<IPacket> getAck() const { return m_ack; };
~PublishResult() noexcept;
PublishResult(const PublishResult &toCopy) noexcept = delete;
PublishResult(PublishResult &&toMove) noexcept = delete;
PublishResult &operator=(const PublishResult &toCopy) noexcept = delete;
PublishResult &operator=(PublishResult &&toMove) noexcept = delete;
private:
std::shared_ptr<IPacket> m_ack;
int m_errorCode;
};
/**
* Configures a single subscription within a Subscribe operation
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*/
class AWS_CRT_CPP_API Subscription
{
public:
Subscription(Allocator *allocator = ApiAllocator());
Subscription(Crt::String topicFilter, Mqtt5::QOS qos, Allocator *allocator = ApiAllocator());
/**
* Sets topic filter to subscribe to
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*
* @param topicFilter string
* @return The Subscription Object after setting the reason string.
*/
Subscription &withTopicFilter(Crt::String topicFilter) noexcept;
/**
* Sets Maximum QoS on which the subscriber will accept publish messages. Negotiated QoS may be
* different.
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*
* @param QOS
* @return The Subscription Object after setting the reason string.
*/
Subscription &withQOS(Mqtt5::QOS QOS) noexcept;
/**
* Sets should the server not send publishes to a client when that client was the one who sent the
* publish? The value will be default to false.
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*
* @param noLocal bool
* @return The Subscription Object after setting the reason string.
*/
Subscription &withNoLocal(bool noLocal) noexcept;
/**
* Sets should the server not send publishes to a client when that client was the one who sent the
* publish? The value will be default to false.
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*
* @param retain bool
* @return The Subscription Object after setting the reason string.
*/
Subscription &withRetain(bool retain) noexcept;
/**
* Sets should messages sent due to this subscription keep the retain flag preserved on the message?
* The value will be default to false.
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*
* @param retainHandlingType
* @return The Subscription Object after setting the reason string.
*/
Subscription &withRetainHandlingType(RetainHandlingType retainHandlingType) noexcept;
bool initializeRawOptions(aws_mqtt5_subscription_view &raw_options) const noexcept;
virtual ~Subscription(){};
Subscription(const Subscription &) noexcept;
Subscription(Subscription &&) noexcept;
Subscription &operator=(const Subscription &) noexcept;
Subscription &operator=(Subscription &&) noexcept;
private:
Allocator *m_allocator;
/**
* Topic filter to subscribe to
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*/
Crt::String m_topicFilter;
/**
* Maximum QoS on which the subscriber will accept publish messages. Negotiated QoS may be different.
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*/
Mqtt5::QOS m_qos;
/**
* Should the server not send publishes to a client when that client was the one who sent the publish?
* If undefined, this is assumed to be false.
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*/
bool m_noLocal;
/**
* Should messages sent due to this subscription keep the retain flag preserved on the message? If
* undefined, this is assumed to be false.
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*/
bool m_retain;
/**
* Should retained messages on matching topics be sent in reaction to this subscription? If undefined,
* this is assumed to be RetainHandlingType.SendOnSubscribe.
*
* See [MQTT5 Subscription
* Options](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901169)
*/
RetainHandlingType m_retainHnadlingType;
};
/**
* Data model of an [MQTT5
* SUBSCRIBE](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901161) packet.
*/
class AWS_CRT_CPP_API SubscribePacket : public IPacket
{
public:
SubscribePacket(Allocator *allocator = ApiAllocator()) noexcept;
/* The packet type */
PacketType getType() override { return PacketType::AWS_MQTT5_PT_SUBSCRIBE; };
/**
* Sets the list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*
* @param userProperties List of MQTT5 user properties included with the packet.
* @return the SubscribePacket Object after setting the reason string.
*/
SubscribePacket &withUserProperties(const Vector<UserProperty> &userProperties) noexcept;
/**
* Sets the list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*
* @param userProperties List of MQTT5 user properties included with the packet.
* @return the SubscribePacket Object after setting the reason string.
*/
SubscribePacket &withUserProperties(Vector<UserProperty> &&userProperties) noexcept;
/**
* Put a MQTT5 user property to the back of the packet user property vector/list
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*
* @param property userProperty of MQTT5 user properties included with the packet.
* @return The SubscribePacket Object after setting the user property
*/
SubscribePacket &withUserProperty(UserProperty &&property) noexcept;
/**
* Sets the value to associate with all subscriptions in this request. Publish packets that
* match a subscription in this request should include this identifier in the resulting message.
*
* See [MQTT5 Subscription
* Identifier](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901166)
*
* @param subscriptionIdentifier A positive long to associate with all subscriptions in this request.
* @return The SubscribePacket Object after setting the subscription identifier.
*/
SubscribePacket &withSubscriptionIdentifier(uint32_t subscriptionIdentifier) noexcept;
/**
* Sets a list of subscriptions within the SUBSCRIBE packet.
*
* @param subscriptions vector of subscriptions to add within the SUBSCRIBE packet.
*
* @return The SubscribePacket Object after setting the subscription.
*/
SubscribePacket &withSubscriptions(const Vector<Subscription> &subscriptions) noexcept;
/**
* Sets a list of subscriptions within the SUBSCRIBE packet.
*
* @param subscriptions vector of subscriptions to add within the SUBSCRIBE packet.
*
* @return The SubscribePacket Object after setting the subscription.
*/
SubscribePacket &withSubscriptions(Crt::Vector<Subscription> &&subscriptions) noexcept;
/**
* Sets a single subscription within the SUBSCRIBE packet.
*
* @param subscription The subscription to add within the SUBSCRIBE packet.
*
* @return The SubscribePacket Object after setting the subscription.
*/
SubscribePacket &withSubscription(Subscription &&subscription) noexcept;
bool initializeRawOptions(aws_mqtt5_packet_subscribe_view &raw_options) noexcept;
virtual ~SubscribePacket();
SubscribePacket(const SubscribePacket &) noexcept = delete;
SubscribePacket(SubscribePacket &&) noexcept = delete;
SubscribePacket &operator=(const SubscribePacket &) noexcept = delete;
SubscribePacket &operator=(SubscribePacket &&) noexcept = delete;
private:
Allocator *m_allocator;
/**
* List of topic filter subscriptions that the client wishes to listen to
*
* See [MQTT5 Subscribe
* Payload](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901168)
*/
Crt::Vector<Subscription> m_subscriptions;
/**
* A positive integer to associate with all subscriptions in this request. Publish packets that match
* a subscription in this request should include this identifier in the resulting message.
*
* See [MQTT5 Subscription
* Identifier](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901166)
*/
Crt::Optional<uint32_t> m_subscriptionIdentifier;
/**
* Set of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901167)
*/
Crt::Vector<UserProperty> m_userProperties;
///////////////////////////////////////////////////////////////////////////
// Underlying data storage for internal use
///////////////////////////////////////////////////////////////////////////
struct aws_mqtt5_subscription_view *m_subscriptionViewStorage;
struct aws_mqtt5_user_property *m_userPropertiesStorage;
};
/**
* Data model of an [MQTT5
* SUBACK](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901171) packet.
*/
class AWS_CRT_CPP_API SubAckPacket : public IPacket
{
public:
SubAckPacket(
const aws_mqtt5_packet_suback_view &packet,
Allocator *allocator = ApiAllocator()) noexcept;
/* The packet type */
PacketType getType() override { return PacketType::AWS_MQTT5_PT_SUBACK; };
/**
* Returns additional diagnostic information about the result of the SUBSCRIBE attempt.
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901176)
*
* @return Additional diagnostic information about the result of the SUBSCRIBE attempt.
*/
const Crt::Optional<Crt::String> &getReasonString() const noexcept;
/**
* Returns list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901177)
*
* @return List of MQTT5 user properties included with the packet.
*/
const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
/**
* Returns list of reason codes indicating the result of each individual subscription entry in the
* associated SUBSCRIBE packet.
*
* See [MQTT5 Suback
* Payload](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901178)
*
* @return list of reason codes indicating the result of each individual subscription entry in the
* associated SUBSCRIBE packet.
*/
const Crt::Vector<SubAckReasonCode> &getReasonCodes() const noexcept;
virtual ~SubAckPacket() { m_userProperties.clear(); };
SubAckPacket(const SubAckPacket &) noexcept = delete;
SubAckPacket(SubAckPacket &&) noexcept = delete;
SubAckPacket &operator=(const SubAckPacket &) noexcept = delete;
SubAckPacket &operator=(SubAckPacket &&) noexcept = delete;
private:
/**
* A list of reason codes indicating the result of each individual subscription entry in the
* associated SUBSCRIBE packet.
*
* See [MQTT5 Suback
* Payload](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901178)
*/
Crt::Vector<SubAckReasonCode> m_reasonCodes;
/**
* Additional diagnostic information about the result of the SUBSCRIBE attempt.
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901176)
*/
Crt::Optional<Crt::String> m_reasonString;
/**
* Set of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901177)
*/
Crt::Vector<UserProperty> m_userProperties;
};
/**
* Data model of an [MQTT5
* UNSUBSCRIBE](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901179) packet.
*/
class AWS_CRT_CPP_API UnsubscribePacket : public IPacket
{
public:
UnsubscribePacket(Allocator *allocator = ApiAllocator()) noexcept;
/* The packet type */
PacketType getType() override { return PacketType::AWS_MQTT5_PT_UNSUBSCRIBE; };
/**
* Push back a topic filter that the client wishes to unsubscribe from.
*
* @param topicFilter that the client wishes to unsubscribe from
*
* @return The UnsubscribePacket Object after setting the subscription.
*/
UnsubscribePacket &withTopicFilter(Crt::String topicFilter) noexcept;
/**
* Sets list of topic filter that the client wishes to unsubscribe from.
*
* @param topicFilters vector of subscription topic filters that the client wishes to unsubscribe from
*
* @return The UnsubscribePacket Object after setting the subscription.
*/
UnsubscribePacket &withTopicFilters(Crt::Vector<String> topicFilters) noexcept;
/**
* Sets the list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901184)
*
* @param userProperties List of MQTT5 user properties included with the packet.
* @return The UnsubscribePacketBuilder after setting the user properties.
*/
UnsubscribePacket &withUserProperties(const Vector<UserProperty> &userProperties) noexcept;
/**
* Sets the list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901184)
*
* @param userProperties List of MQTT5 user properties included with the packet.
* @return The UnsubscribePacketBuilder after setting the user properties.
*/
UnsubscribePacket &withUserProperties(Vector<UserProperty> &&userProperties) noexcept;
/**
* Put a MQTT5 user property to the back of the packet user property vector/list
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116)
*
* @param property set of userProperty of MQTT5 user properties included with the packet.
* @return The PublishPacket Object after setting the user property
*/
UnsubscribePacket &withUserProperty(UserProperty &&property) noexcept;
bool initializeRawOptions(aws_mqtt5_packet_unsubscribe_view &raw_options) noexcept;
virtual ~UnsubscribePacket();
UnsubscribePacket(const UnsubscribePacket &) noexcept = delete;
UnsubscribePacket(UnsubscribePacket &&) noexcept = delete;
UnsubscribePacket &operator=(const UnsubscribePacket &) noexcept = delete;
UnsubscribePacket &operator=(UnsubscribePacket &&) noexcept = delete;
private:
Allocator *m_allocator;
/**
* List of topic filters that the client wishes to unsubscribe from.
*
* See [MQTT5 Unsubscribe
* Payload](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901185)
*/
Crt::Vector<String> m_topicFilters;
/**
* Set of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901184)
*/
Crt::Vector<UserProperty> m_userProperties;
///////////////////////////////////////////////////////////////////////////
// Underlying data storage for internal use
///////////////////////////////////////////////////////////////////////////
struct aws_array_list m_topicFiltersList;
struct aws_mqtt5_user_property *m_userPropertiesStorage;
};
/**
* Data model of an [MQTT5
* UNSUBACK](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901187) packet.
*/
class AWS_CRT_CPP_API UnSubAckPacket : public IPacket
{
public:
UnSubAckPacket(
const aws_mqtt5_packet_unsuback_view &packet,
Allocator *allocator = ApiAllocator()) noexcept;
/* The packet type */
PacketType getType() override { return PacketType::AWS_MQTT5_PT_UNSUBACK; };
/**
* Returns additional diagnostic information about the result of the UNSUBSCRIBE attempt.
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901192)
*
* @return Additional diagnostic information about the result of the UNSUBSCRIBE attempt.
*/
const Crt::Optional<Crt::String> &getReasonString() const noexcept;
/**
* Returns list of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901193)
*
* @return List of MQTT5 user properties included with the packet.
*/
const Crt::Vector<UserProperty> &getUserProperties() const noexcept;
/**
* Returns a list of reason codes indicating the result of unsubscribing from each individual topic
* filter entry in the associated UNSUBSCRIBE packet.
*
* See [MQTT5 Unsuback
* Payload](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901194)
*
* @return A list of reason codes indicating the result of unsubscribing from each individual topic
* filter entry in the associated UNSUBSCRIBE packet.
*/
const Crt::Vector<UnSubAckReasonCode> &getReasonCodes() const noexcept;
virtual ~UnSubAckPacket() { m_userProperties.clear(); };
UnSubAckPacket(const UnSubAckPacket &) noexcept = delete;
UnSubAckPacket(UnSubAckPacket &&) noexcept = delete;
UnSubAckPacket &operator=(const UnSubAckPacket &) noexcept = delete;
UnSubAckPacket &operator=(UnSubAckPacket &&) noexcept = delete;
private:
/**
* Additional diagnostic information about the result of the UNSUBSCRIBE attempt.
*
* See [MQTT5 Reason
* String](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901192)
*/
Crt::Optional<Crt::String> m_reasonString;
/**
* Set of MQTT5 user properties included with the packet.
*
* See [MQTT5 User
* Property](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901193)
*/
Crt::Vector<UserProperty> m_userProperties;
/**
* A list of reason codes indicating the result of unsubscribing from each individual topic filter entry
* in the associated UNSUBSCRIBE packet.
*
* See [MQTT5 Unsuback
* Payload](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901194)
*/
Crt::Vector<UnSubAckReasonCode> m_reasonCodes;
};
} // namespace Mqtt5
} // namespace Crt
} // namespace Aws
|