blob: e77027e8234fe656b74695c23fc0ece7b02cf5ce (
plain)
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
|
#pragma once
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <vector>
class CChatManager {
public:
CChatManager();
~CChatManager();
struct SMessage {
std::string msg;
std::string username;
std::optional<uintptr_t> sender = std::nullopt; // cant include session to use CSession* cause circular dependency
bool admin = false;
};
void newMessage(const SMessage &msg);
std::string fmtBroadcastMessage(const SMessage &msg);
std::vector<SMessage> getChat() const;
private:
mutable std::mutex m_mutex;
};
inline std::unique_ptr<CChatManager> g_pChatManager;
|