mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
UICommon: Add NetPlayIndex helper
This commit is contained in:
65
Source/Core/UICommon/NetPlayIndex.h
Normal file
65
Source/Core/UICommon/NetPlayIndex.h
Normal file
@ -0,0 +1,65 @@
|
||||
// Copyright 2019 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Flag.h"
|
||||
|
||||
struct NetPlaySession
|
||||
{
|
||||
std::string name;
|
||||
std::string region;
|
||||
std::string method;
|
||||
std::string server_id;
|
||||
std::string game_id;
|
||||
|
||||
int player_count;
|
||||
int port;
|
||||
|
||||
bool has_password;
|
||||
bool in_game;
|
||||
|
||||
bool EncryptID(const std::string& password);
|
||||
std::optional<std::string> DecryptID(const std::string& password) const;
|
||||
};
|
||||
|
||||
class NetPlayIndex
|
||||
{
|
||||
public:
|
||||
explicit NetPlayIndex();
|
||||
~NetPlayIndex();
|
||||
|
||||
std::optional<std::vector<NetPlaySession>>
|
||||
List(const std::map<std::string, std::string>& filters = {});
|
||||
|
||||
static std::vector<std::string> GetRegions();
|
||||
|
||||
bool Add(NetPlaySession session);
|
||||
void Remove();
|
||||
|
||||
void SetPlayerCount(int player_count);
|
||||
void SetInGame(bool in_game);
|
||||
void SetGame(const std::string& game);
|
||||
|
||||
const std::string& GetLastError() const;
|
||||
|
||||
private:
|
||||
void NotificationLoop();
|
||||
|
||||
Common::Flag m_running;
|
||||
|
||||
std::string m_secret;
|
||||
std::string m_game;
|
||||
int m_player_count = 0;
|
||||
bool m_in_game = false;
|
||||
|
||||
std::string m_last_error;
|
||||
std::thread m_session_thread;
|
||||
};
|
Reference in New Issue
Block a user