Botcraft 26.3
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 <vector>
5
6#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
7#include <deque>
8
10#else
11#include <array>
12#endif
13
15
16namespace Botcraft
17{
18 /// @brief Tracks last seen messages for chat signing.
19 /// Not thread-safe: the owner (NetworkManager) must hold a mutex lock when using it.
21 {
22 public:
25
26#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
27 const std::vector<unsigned char>& GetLastSignature() const;
28 void SetLastSignature(const std::vector<unsigned char>& last_signature_sent_);
29
30 void AddSeenMessage(const std::vector<unsigned char>& signature, const ProtocolCraft::UUID& sender);
31
33#else
34 /// @brief Get both a vector of previous messages signatures and the LastSeenMessagesUpdate object
35 /// @return A pair with both items
36 std::pair<std::vector<std::vector<unsigned char>>, ProtocolCraft::LastSeenMessagesUpdate> GetLastSeenMessagesUpdate();
37
38 void AddSeenMessage(const std::vector<unsigned char>& signature);
39
40 int GetOffset() const;
42#endif
43
44 private:
45#if PROTOCOL_VERSION < 761 /* < 1.19.3 */
46 std::vector<unsigned char> last_signature_sent;
47 std::deque<ProtocolCraft::LastSeenMessagesEntry> last_seen;
48#else
49 /// @brief Circular buffer to store previously seen message signatures
50 std::array<std::vector<unsigned char>, 20> last_seen_signatures;
51 size_t tail;
52 int offset;
53#endif
54 };
55}
56#endif
Tracks last seen messages for chat signing.
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