Verbessere Benutzerverwaltung in ChatRoom durch Überprüfung auf Elternobjekt

- Füge eine Bedingung hinzu, um sicherzustellen, dass `_parent` vor dem Abrufen der Raumliste nicht null ist, um potenzielle Fehler zu vermeiden.
- Entferne überflüssige Kommentare und verbessere die Lesbarkeit des Codes in der `chat_room.cpp`.
This commit is contained in:
Torsten Schulz (local)
2025-09-05 09:16:27 +02:00
parent 62a5c70c8c
commit 39780197f8
2 changed files with 5 additions and 3 deletions

View File

@@ -116,8 +116,10 @@ namespace Yc
auto newUser = std::make_shared<ChatUser>(shared_from_this(), _userName, color, socket);
_users.push_back(newUser);
newUser->start();
Json::Value roomList = _parent->jsonRoomList();
newUser->sendMsg(ChatUser::roomList, roomList, "", "");
if (_parent) {
Json::Value roomList = _parent->jsonRoomList();
newUser->sendMsg(ChatUser::roomList, roomList, "", "");
}
// Sende aktuelle Userliste an den neuen User
Json::Value currentUserList = userList();