2021-12-25 11:27:52 -08: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"
|
|
|
|
#include "web_service/web_backend.h"
|
|
|
|
|
|
|
|
namespace WebService {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of AnnounceMultiplayerRoom::Backend that (de)serializes room information into/from
|
|
|
|
* JSON, and submits/gets it to/from the yuzu web service
|
|
|
|
*/
|
|
|
|
class RoomJson : public AnnounceMultiplayerRoom::Backend {
|
|
|
|
public:
|
2022-07-11 11:40:57 -07:00
|
|
|
RoomJson(const std::string& host_, const std::string& username_, const std::string& token_)
|
|
|
|
: client(host_, username_, token_), host(host_), username(username_), token(token_) {}
|
2021-12-25 11:27:52 -08:00
|
|
|
~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,
|
2022-07-17 20:53:44 -07:00
|
|
|
const AnnounceMultiplayerRoom::GameInfo& preferred_game) override;
|
2022-07-15 12:11:09 -07:00
|
|
|
void AddPlayer(const AnnounceMultiplayerRoom::Member& member) override;
|
2021-12-25 11:27:52 -08:00
|
|
|
WebResult Update() override;
|
|
|
|
WebResult Register() override;
|
|
|
|
void ClearPlayers() override;
|
|
|
|
AnnounceMultiplayerRoom::RoomList GetRoomList() override;
|
|
|
|
void Delete() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
AnnounceMultiplayerRoom::Room room;
|
|
|
|
Client client;
|
|
|
|
std::string host;
|
|
|
|
std::string username;
|
|
|
|
std::string token;
|
|
|
|
std::string room_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace WebService
|