Refactor chat room implementation

- Renamed Room class to ChatRoom and updated all references accordingly.
- Removed the old room.cpp and room.h files.
- Updated CMakeLists.txt to include chat_room.cpp instead of room.cpp.
- Modified ChatUser class to use shared_ptr<ChatRoom> instead of shared_ptr<Room>.
- Updated Server class to create instances of ChatRoom instead of Room.
- Removed User class and its associated files, integrating its functionality into ChatUser.
- Ensured all relevant includes and dependencies are updated to reflect the new class structure.
This commit is contained in:
Torsten Schulz (local)
2025-08-11 15:03:11 +02:00
parent b81f2de10f
commit 6ecdbda9de
9 changed files with 48 additions and 456 deletions

View File

@@ -1,21 +1,18 @@
#ifndef YC_LIB_CHAT_USER_H
#define YC_LIB_CHAT_USER_H
#include <memory>
#include <string>
#include <set>
#include <json/json.h>
#include <thread>
#include "base.h"
// Forward declaration to break cyclic dependency
namespace Yc { namespace Lib { class Room; } }
namespace Yc {
namespace Lib {
class ChatRoom;
class ChatUser: public Base, public std::enable_shared_from_this<ChatUser> {
public:
enum MsgType {
@@ -31,7 +28,7 @@ public:
result = 9
};
ChatUser(std::shared_ptr<Room> parent, std::string name, std::string color, int socket);
ChatUser(std::shared_ptr<ChatRoom> parent, std::string name, std::string color, int socket);
~ChatUser();
std::string name() const;
bool validateToken(std::string token);
@@ -42,10 +39,10 @@ public:
void checkerTask();
void stop();
std::string color() const;
void setParent(std::shared_ptr<Room> parent);
void setParent(std::shared_ptr<ChatRoom> parent);
private:
std::shared_ptr<Room> _parent;
std::shared_ptr<ChatRoom> _parent;
std::string _name;
std::string _color;
int _socket;