mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Qt/NetPlay: Show feedback for index adding
This commit is contained in:
@ -142,6 +142,8 @@ void NetPlayIndex::NotificationLoop()
|
||||
if (!json)
|
||||
{
|
||||
m_last_error = "BAD_JSON";
|
||||
m_secret.clear();
|
||||
m_error_callback();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -150,6 +152,8 @@ void NetPlayIndex::NotificationLoop()
|
||||
if (status != "OK")
|
||||
{
|
||||
m_last_error = std::move(status);
|
||||
m_secret.clear();
|
||||
m_error_callback();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -318,3 +322,13 @@ const std::string& NetPlayIndex::GetLastError() const
|
||||
{
|
||||
return m_last_error;
|
||||
}
|
||||
|
||||
bool NetPlayIndex::HasActiveSession() const
|
||||
{
|
||||
return !m_secret.empty();
|
||||
}
|
||||
|
||||
void NetPlayIndex::SetErrorCallback(std::function<void()> function)
|
||||
{
|
||||
m_error_callback = function;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@ -46,12 +47,16 @@ public:
|
||||
bool Add(NetPlaySession session);
|
||||
void Remove();
|
||||
|
||||
bool HasActiveSession() const;
|
||||
|
||||
void SetPlayerCount(int player_count);
|
||||
void SetInGame(bool in_game);
|
||||
void SetGame(std::string game);
|
||||
|
||||
const std::string& GetLastError() const;
|
||||
|
||||
void SetErrorCallback(std::function<void()> callback);
|
||||
|
||||
private:
|
||||
void NotificationLoop();
|
||||
|
||||
@ -64,4 +69,6 @@ private:
|
||||
std::thread m_session_thread;
|
||||
|
||||
Common::Event m_session_thread_exit_event;
|
||||
|
||||
std::function<void()> m_error_callback = nullptr;
|
||||
};
|
||||
|
Reference in New Issue
Block a user