Botcraft 1.21.4
Loading...
Searching...
No Matches
LastSeenMessagesTracker.hpp
Go to the documentation of this file.
1#if PROTOCOL_VERSION > 759 /* > 1.19 */
2#pragma once
3
4#include <mutex>
5#include <vector>
6
7#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
8#include <deque>
9
11#else
12#include <array>
13#endif
14
16
17namespace Botcraft
18{
20 {
21 public:
24
25 std::mutex& GetMutex();
26
27#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
28 const std::vector<unsigned char>& GetLastSignature() const;
29 void SetLastSignature(const std::vector<unsigned char>& last_signature_sent_);
30
31 void AddSeenMessage(const std::vector<unsigned char>& signature, const ProtocolCraft::UUID& sender);
32
34#else
35 /// @brief Get both a vector of previous messages signatures and the LastSeenMessagesUpdate object
36 /// @return A pair with both items
37 std::pair<std::vector<std::vector<unsigned char>>, ProtocolCraft::LastSeenMessagesUpdate> GetLastSeenMessagesUpdate();
38
39 void AddSeenMessage(const std::vector<unsigned char>& signature);
40
41 int GetOffset() const;
43#endif
44
45 private:
46 std::mutex mutex;
47#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
48 std::vector<unsigned char> last_signature_sent;
49 std::deque<ProtocolCraft::LastSeenMessagesEntry> last_seen;
50#else
51 /// @brief Circular buffer to store previously seen message signatures
52 std::array<std::vector<unsigned char>, 20> last_seen_signatures;
53 size_t tail;
54 int offset;
55#endif
56 };
57}
58#endif
std::array< std::vector< unsigned char >, 20 > last_seen_signatures
Circular buffer to store previously seen message signatures.
void AddSeenMessage(const std::vector< unsigned char > &signature)
std::pair< std::vector< std::vector< unsigned char > >, ProtocolCraft::LastSeenMessagesUpdate > GetLastSeenMessagesUpdate()
Get both a vector of previous messages signatures and the LastSeenMessagesUpdate object.
std::array< unsigned char, 16 > UUID