-
Notifications
You must be signed in to change notification settings - Fork 0
/
BroadcastMessageQueue.hh
44 lines (32 loc) · 1.17 KB
/
BroadcastMessageQueue.hh
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
#pragma once
#include "ClientManager.hh"
#include "IMessageQueue.hh"
#include "Uuid.hh"
#include <core_utils/CoreObject.hh>
#include <deque>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <vector>
namespace bsgo {
class BroadcastMessageQueue : public IMessageQueue, public utils::CoreObject
{
public:
BroadcastMessageQueue(ClientManagerShPtr clientManager);
~BroadcastMessageQueue() override = default;
void pushMessage(IMessagePtr message) override;
void addListener(IMessageListenerPtr listener) override;
bool empty() override;
void processMessages(const std::optional<int> &amount = {}) override;
private:
std::mutex m_locker{};
std::deque<IMessagePtr> m_messages{};
ClientManagerShPtr m_clientManager{};
void processMessage(const IMessage &message);
void sendMessageToClient(const Uuid clientId, const IMessage &message);
void broadcastMessage(const IMessage &message);
auto tryDetermineClientId(const IMessage &message) const -> std::optional<Uuid>;
auto tryDetermineSystemIds(const IMessage &message) const -> std::vector<Uuid>;
};
using BroadcastMessageQueuePtr = std::unique_ptr<BroadcastMessageQueue>;
} // namespace bsgo