mqttpacket.h
815 Bytes
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
#ifndef MQTTPACKET_H
#define MQTTPACKET_H
#include "unistd.h"
#include <memory>
#include <vector>
#include <exception>
#include "client.h"
#include "exceptions.h"
#include "types.h"
class Client;
class MqttPacket
{
bool valid = false;
std::vector<char> bites;
const size_t fixed_header_length;
uint16_t variable_header_length;
Client *sender;
std::string clientid;
size_t pos = 0;
ProtocolVersion protocolVersion = ProtocolVersion::None;
public:
PacketType packetType = PacketType::Reserved;
MqttPacket(char *buf, size_t len, size_t fixed_header_length, Client *sender);
bool isValid() { return valid; }
std::string getClientId();
void handle();
void handleConnect();
char *readBytes(size_t length);
char readByte();
};
#endif // MQTTPACKET_H