forked from halfgaar/FlashMQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mqtt5properties.h
67 lines (56 loc) · 2.63 KB
/
mqtt5properties.h
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
/*
This file is part of FlashMQ (https://www.flashmq.org)
Copyright (C) 2021-2023 Wiebe Cazemier
FlashMQ is free software: you can redistribute it and/or modify
it under the terms of The Open Software License 3.0 (OSL-3.0).
See LICENSE for license details.
*/
#ifndef MQTT5PROPERTIES_H
#define MQTT5PROPERTIES_H
#include <vector>
#include "types.h"
#include "variablebyteint.h"
class Mqtt5PropertyBuilder
{
std::vector<char> genericBytes;
std::vector<char> clientSpecificBytes; // only relevant for publishes
std::shared_ptr<std::vector<std::pair<std::string, std::string>>> userProperties;
VariableByteInt length;
int userPropertyCount = 0;
void writeUint32(Mqtt5Properties prop, const uint32_t x, std::vector<char> &target) const;
void writeUint16(Mqtt5Properties prop, const uint16_t x);
void writeUint16(Mqtt5Properties prop, const uint16_t x, std::vector<char> &target) const;
void writeUint8(Mqtt5Properties prop, const uint8_t x);
void writeStr(Mqtt5Properties prop, const std::string &str);
void write2Str(Mqtt5Properties prop, const std::string &one, const std::string &two);
public:
Mqtt5PropertyBuilder();
size_t getLength();
const VariableByteInt &getVarInt();
const std::vector<char> &getGenericBytes() const;
const std::vector<char> &getclientSpecificBytes() const;
void clearClientSpecificBytes();
std::shared_ptr<std::vector<std::pair<std::string, std::string>>> getUserProperties() const;
void writeServerKeepAlive(uint16_t val);
void writeSessionExpiry(uint32_t val);
void writeReceiveMax(uint16_t val);
void writeRetainAvailable(uint8_t val);
void writeMaxPacketSize(uint32_t val);
void writeAssignedClientId(const std::string &clientid);
void writeMaxTopicAliases(uint16_t val);
void writeWildcardSubscriptionAvailable(uint8_t val);
void writeSubscriptionIdentifiersAvailable(uint8_t val);
void writeSharedSubscriptionAvailable(uint8_t val);
void writeContentType(const std::string &format);
void writePayloadFormatIndicator(uint8_t val);
void writeMessageExpiryInterval(uint32_t val);
void writeResponseTopic(const std::string &str);
void writeUserProperty(std::string &&key, std::string &&value);
void writeCorrelationData(const std::string &correlationData);
void writeTopicAlias(const uint16_t id);
void writeAuthenticationMethod(const std::string &method);
void writeAuthenticationData(const std::string &data);
void writeWillDelay(uint32_t delay);
void setNewUserProperties(const std::shared_ptr<std::vector<std::pair<std::string, std::string>>> &userProperties);
};
#endif // MQTT5PROPERTIES_H