From 899c8bb33094f43fbd8df9afb4ca84718ebac87e Mon Sep 17 00:00:00 2001 From: german77 Date: Sun, 17 Jul 2022 22:53:44 -0500 Subject: common: multiplayer: Use GameInfo type --- src/web_service/announce_room_json.cpp | 21 ++++++++++----------- src/web_service/announce_room_json.h | 3 +-- src/web_service/verify_user_jwt.h | 2 ++ 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/web_service') diff --git a/src/web_service/announce_room_json.cpp b/src/web_service/announce_room_json.cpp index 84220b851..082bebaa9 100644 --- a/src/web_service/announce_room_json.cpp +++ b/src/web_service/announce_room_json.cpp @@ -19,14 +19,14 @@ static void to_json(nlohmann::json& json, const Member& member) { if (!member.avatar_url.empty()) { json["avatarUrl"] = member.avatar_url; } - json["gameName"] = member.game_name; - json["gameId"] = member.game_id; + json["gameName"] = member.game.name; + json["gameId"] = member.game.id; } static void from_json(const nlohmann::json& json, Member& member) { member.nickname = json.at("nickname").get(); - member.game_name = json.at("gameName").get(); - member.game_id = json.at("gameId").get(); + member.game.name = json.at("gameName").get(); + member.game.id = json.at("gameId").get(); try { member.username = json.at("username").get(); member.avatar_url = json.at("avatarUrl").get(); @@ -42,8 +42,8 @@ static void to_json(nlohmann::json& json, const Room& room) { if (!room.information.description.empty()) { json["description"] = room.information.description; } - json["preferredGameName"] = room.information.preferred_game; - json["preferredGameId"] = room.information.preferred_game_id; + json["preferredGameName"] = room.information.preferred_game.name; + json["preferredGameId"] = room.information.preferred_game.id; json["maxPlayers"] = room.information.member_slots; json["netVersion"] = room.net_version; 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(); room.information.port = json.at("port").get(); - room.information.preferred_game = json.at("preferredGameName").get(); - room.information.preferred_game_id = json.at("preferredGameId").get(); + room.information.preferred_game.name = json.at("preferredGameName").get(); + room.information.preferred_game.id = json.at("preferredGameId").get(); room.information.member_slots = json.at("maxPlayers").get(); room.net_version = json.at("netVersion").get(); room.has_password = json.at("hasPassword").get(); @@ -83,8 +83,8 @@ namespace WebService { void RoomJson::SetRoomInformation(const std::string& name, const std::string& description, const u16 port, const u32 max_player, const u32 net_version, - const bool has_password, const std::string& preferred_game, - const u64 preferred_game_id) { + const bool has_password, + const AnnounceMultiplayerRoom::GameInfo& preferred_game) { room.information.name = name; room.information.description = description; 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.has_password = has_password; room.information.preferred_game = preferred_game; - room.information.preferred_game_id = preferred_game_id; } void RoomJson::AddPlayer(const AnnounceMultiplayerRoom::Member& member) { room.members.push_back(member); diff --git a/src/web_service/announce_room_json.h b/src/web_service/announce_room_json.h index 811c76fbd..24ec29c65 100644 --- a/src/web_service/announce_room_json.h +++ b/src/web_service/announce_room_json.h @@ -22,8 +22,7 @@ public: ~RoomJson() = default; void SetRoomInformation(const std::string& name, const std::string& description, const u16 port, const u32 max_player, const u32 net_version, const bool has_password, - const std::string& preferred_game, - const u64 preferred_game_id) override; + const AnnounceMultiplayerRoom::GameInfo& preferred_game) override; void AddPlayer(const AnnounceMultiplayerRoom::Member& member) override; WebResult Update() override; WebResult Register() override; diff --git a/src/web_service/verify_user_jwt.h b/src/web_service/verify_user_jwt.h index 826e01eed..6db74c208 100644 --- a/src/web_service/verify_user_jwt.h +++ b/src/web_service/verify_user_jwt.h @@ -10,6 +10,8 @@ namespace WebService { +std::string GetPublicKey(const std::string& host); + class VerifyUserJWT final : public Network::VerifyUser::Backend { public: VerifyUserJWT(const std::string& host); -- cgit v1.2.3