-
Notifications
You must be signed in to change notification settings - Fork 23
/
mqtt5properties.h
63 lines (52 loc) · 2.25 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
/*
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> bytes;
VariableByteInt length;
int userPropertyCount = 0;
void writeUint32(Mqtt5Properties prop, const uint32_t x);
void writeUint16(Mqtt5Properties prop, const uint16_t x);
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);
void writeVariableByteInt(Mqtt5Properties prop, const unsigned int val);
public:
Mqtt5PropertyBuilder();
size_t getLength();
const VariableByteInt &getVarInt();
const std::vector<char> &getBytes() 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 writeSubscriptionIdentifier(uint32_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 writeUserProperties(const std::vector<std::pair<std::string, std::string>> &properties);
void writeUserProperty(const std::string &key, const 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);
};
#endif // MQTT5PROPERTIES_H