|
|
@ -19,14 +19,14 @@ static void to_json(nlohmann::json& json, const Member& member) {
|
|
|
|
if (!member.avatar_url.empty()) {
|
|
|
|
if (!member.avatar_url.empty()) {
|
|
|
|
json["avatarUrl"] = member.avatar_url;
|
|
|
|
json["avatarUrl"] = member.avatar_url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
json["gameName"] = member.game_name;
|
|
|
|
json["gameName"] = member.game.name;
|
|
|
|
json["gameId"] = member.game_id;
|
|
|
|
json["gameId"] = member.game.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void from_json(const nlohmann::json& json, Member& member) {
|
|
|
|
static void from_json(const nlohmann::json& json, Member& member) {
|
|
|
|
member.nickname = json.at("nickname").get<std::string>();
|
|
|
|
member.nickname = json.at("nickname").get<std::string>();
|
|
|
|
member.game_name = json.at("gameName").get<std::string>();
|
|
|
|
member.game.name = json.at("gameName").get<std::string>();
|
|
|
|
member.game_id = json.at("gameId").get<u64>();
|
|
|
|
member.game.id = json.at("gameId").get<u64>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
member.username = json.at("username").get<std::string>();
|
|
|
|
member.username = json.at("username").get<std::string>();
|
|
|
|
member.avatar_url = json.at("avatarUrl").get<std::string>();
|
|
|
|
member.avatar_url = json.at("avatarUrl").get<std::string>();
|
|
|
@ -42,8 +42,8 @@ static void to_json(nlohmann::json& json, const Room& room) {
|
|
|
|
if (!room.information.description.empty()) {
|
|
|
|
if (!room.information.description.empty()) {
|
|
|
|
json["description"] = room.information.description;
|
|
|
|
json["description"] = room.information.description;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
json["preferredGameName"] = room.information.preferred_game;
|
|
|
|
json["preferredGameName"] = room.information.preferred_game.name;
|
|
|
|
json["preferredGameId"] = room.information.preferred_game_id;
|
|
|
|
json["preferredGameId"] = room.information.preferred_game.id;
|
|
|
|
json["maxPlayers"] = room.information.member_slots;
|
|
|
|
json["maxPlayers"] = room.information.member_slots;
|
|
|
|
json["netVersion"] = room.net_version;
|
|
|
|
json["netVersion"] = room.net_version;
|
|
|
|
json["hasPassword"] = room.has_password;
|
|
|
|
json["hasPassword"] = room.has_password;
|
|
|
@ -65,8 +65,8 @@ static void from_json(const nlohmann::json& json, Room& room) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
room.information.host_username = json.at("owner").get<std::string>();
|
|
|
|
room.information.host_username = json.at("owner").get<std::string>();
|
|
|
|
room.information.port = json.at("port").get<u16>();
|
|
|
|
room.information.port = json.at("port").get<u16>();
|
|
|
|
room.information.preferred_game = json.at("preferredGameName").get<std::string>();
|
|
|
|
room.information.preferred_game.name = json.at("preferredGameName").get<std::string>();
|
|
|
|
room.information.preferred_game_id = json.at("preferredGameId").get<u64>();
|
|
|
|
room.information.preferred_game.id = json.at("preferredGameId").get<u64>();
|
|
|
|
room.information.member_slots = json.at("maxPlayers").get<u32>();
|
|
|
|
room.information.member_slots = json.at("maxPlayers").get<u32>();
|
|
|
|
room.net_version = json.at("netVersion").get<u32>();
|
|
|
|
room.net_version = json.at("netVersion").get<u32>();
|
|
|
|
room.has_password = json.at("hasPassword").get<bool>();
|
|
|
|
room.has_password = json.at("hasPassword").get<bool>();
|
|
|
@ -83,8 +83,8 @@ namespace WebService {
|
|
|
|
|
|
|
|
|
|
|
|
void RoomJson::SetRoomInformation(const std::string& name, const std::string& description,
|
|
|
|
void RoomJson::SetRoomInformation(const std::string& name, const std::string& description,
|
|
|
|
const u16 port, const u32 max_player, const u32 net_version,
|
|
|
|
const u16 port, const u32 max_player, const u32 net_version,
|
|
|
|
const bool has_password, const std::string& preferred_game,
|
|
|
|
const bool has_password,
|
|
|
|
const u64 preferred_game_id) {
|
|
|
|
const AnnounceMultiplayerRoom::GameInfo& preferred_game) {
|
|
|
|
room.information.name = name;
|
|
|
|
room.information.name = name;
|
|
|
|
room.information.description = description;
|
|
|
|
room.information.description = description;
|
|
|
|
room.information.port = port;
|
|
|
|
room.information.port = port;
|
|
|
@ -92,7 +92,6 @@ void RoomJson::SetRoomInformation(const std::string& name, const std::string& de
|
|
|
|
room.net_version = net_version;
|
|
|
|
room.net_version = net_version;
|
|
|
|
room.has_password = has_password;
|
|
|
|
room.has_password = has_password;
|
|
|
|
room.information.preferred_game = preferred_game;
|
|
|
|
room.information.preferred_game = preferred_game;
|
|
|
|
room.information.preferred_game_id = preferred_game_id;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void RoomJson::AddPlayer(const AnnounceMultiplayerRoom::Member& member) {
|
|
|
|
void RoomJson::AddPlayer(const AnnounceMultiplayerRoom::Member& member) {
|
|
|
|
room.members.push_back(member);
|
|
|
|
room.members.push_back(member);
|
|
|
|