2017-10-31 04:02:42 -05:00
|
|
|
// Copyright 2017 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
|
|
|
#include "common/announce_multiplayer_room.h"
|
2018-09-12 11:22:48 -05:00
|
|
|
#include "web_service/web_backend.h"
|
2017-10-31 04:02:42 -05:00
|
|
|
|
|
|
|
namespace WebService {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of AnnounceMultiplayerRoom::Backend that (de)serializes room information into/from
|
|
|
|
* JSON, and submits/gets it to/from the Citra web service
|
|
|
|
*/
|
|
|
|
class RoomJson : public AnnounceMultiplayerRoom::Backend {
|
|
|
|
public:
|
2018-09-12 11:22:48 -05:00
|
|
|
RoomJson(const std::string& host, const std::string& username, const std::string& token)
|
|
|
|
: client(host, username, token), host(host), username(username), token(token) {}
|
2017-10-31 04:02:42 -05:00
|
|
|
~RoomJson() = default;
|
2018-10-27 02:40:15 -05:00
|
|
|
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,
|
2017-10-31 04:02:42 -05:00
|
|
|
const std::string& preferred_game,
|
|
|
|
const u64 preferred_game_id) override;
|
2018-10-27 02:40:15 -05:00
|
|
|
void AddPlayer(const std::string& username, const std::string& nickname,
|
|
|
|
const std::string& avatar_url,
|
2017-10-31 04:02:42 -05:00
|
|
|
const AnnounceMultiplayerRoom::MacAddress& mac_address, const u64 game_id,
|
|
|
|
const std::string& game_name) override;
|
2018-10-27 02:40:15 -05:00
|
|
|
Common::WebResult Update() override;
|
2019-04-19 09:55:49 -05:00
|
|
|
Common::WebResult Register() override;
|
2017-10-31 04:02:42 -05:00
|
|
|
void ClearPlayers() override;
|
2018-09-12 11:22:48 -05:00
|
|
|
AnnounceMultiplayerRoom::RoomList GetRoomList() override;
|
2017-10-31 04:02:42 -05:00
|
|
|
void Delete() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
AnnounceMultiplayerRoom::Room room;
|
2018-09-12 11:22:48 -05:00
|
|
|
Client client;
|
|
|
|
std::string host;
|
2017-10-31 04:02:42 -05:00
|
|
|
std::string username;
|
|
|
|
std::string token;
|
2018-10-27 02:40:15 -05:00
|
|
|
std::string room_id;
|
2017-10-31 04:02:42 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace WebService
|