3RoomInfo::RoomInfo() =
default;
4RoomInfo::RoomInfo(QString _room_id,
9 QVector<User> _members,
11 : room_id(std::move(_room_id)),
12 display_name(std::move(_display_name)),
13 invite_code(std::move(_invite_code)),
14 session_id(std::move(_session_id)),
15 host_id(std::move(_host_id)),
16 members(std::move(_members)),
17 session(std::move(_session)) {
19void RoomInfo::read(
const QJsonObject &json) {
20 if (json.contains(ROOM_ID) && json[ROOM_ID].isString()) {
21 room_id = json[ROOM_ID].toString();
24 if (json.contains(DISPLAY_NAME) && json[DISPLAY_NAME].isString()) {
25 display_name = json[DISPLAY_NAME].toString();
28 if (json.contains(INVITE_CODE) && json[INVITE_CODE].isString()) {
29 invite_code = json[INVITE_CODE].toString();
32 if (json.contains(SESSION_ID) && json[SESSION_ID].isString()) {
33 session_id = json[SESSION_ID].toString();
36 if (json.contains(HOST_ID) && json[HOST_ID].isString()) {
37 host_id = json[HOST_ID].toString();
40 if (json.contains(MEMBERS) && json[MEMBERS].isArray()) {
41 for (
auto obj : json[MEMBERS].toArray()) {
42 members.push_back(
User());
43 members.back().read(obj.toObject());
47 if (json.contains(SESSION) && json[SESSION].isObject()) {
48 session.read(json[SESSION].toObject());
49 isSessionAlive =
true;
52void RoomInfo::write(QJsonObject &json)
const {