Update CMake configuration and refactor code to use smart pointers for memory management

This commit is contained in:
Torsten Schulz
2025-08-11 11:15:54 +02:00
parent ba6b788075
commit f44d780537
10 changed files with 110 additions and 77 deletions

View File

@@ -10,20 +10,20 @@
namespace Yc {
namespace Lib {
class Server: public Base
class Server: public Base, public std::enable_shared_from_this<Server>
{
public:
Server(Yc::Lib::Config *config);
Server(std::shared_ptr<Yc::Lib::Config> config);
void run();
std::vector<std::string> roomList();
Json::Value jsonRoomList();
bool roomAllowed(std::string roomName, std::string userName, std::string password);
bool changeRoom(User *user, std::string newRoom, std::string password);
bool changeRoom(std::shared_ptr<User> user, std::string newRoom, std::string password);
private:
int _socket;
Yc::Lib::Config *_config;
std::shared_ptr<Yc::Lib::Config> _config;
bool _stop;
std::vector<Yc::Lib::Room*> _rooms;
std::vector<std::shared_ptr<Yc::Lib::Room>> _rooms;
void createRooms(Json::Value roomList);
void handleRequest();
void inputSwitcher(int userSocket, std::string input);