blob: ea5fce974e88d7b2bd77a960b8f33a0bbdd66107 (
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 "format.hpp"
#include "session.hpp"
#include <memory>
#include <thread>
#include <vector>
class CSessionManager {
public:
CSessionManager();
~CSessionManager();
std::pair<std::jthread, std::shared_ptr<CSession>> *newSession(Hyprutils::OS::CFileDescriptor sockfd);
void enterLoop();
void broadcast(const std::string &msg, eFormatType type = NONE) const;
void kick(const CSession *session) const;
void addSession(const CSession &session);
void removeSession(std::pair<std::jthread, std::shared_ptr<CSession>> *session);
private:
void broadcastChat(const std::string &msg, const std::string &username) const;
std::vector<std::pair<std::jthread, std::shared_ptr<CSession>>> m_vSessions;
friend class CChatManager;
};
inline std::shared_ptr<CSessionManager> g_pSessionManager;
|