mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-01 15:25:33 +01:00
46 lines
770 B
C++
46 lines
770 B
C++
// Copyright 2018 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#include "DolphinQt2/DiscordHandler.h"
|
|
|
|
#include "Common/Thread.h"
|
|
|
|
#include "UICommon/DiscordPresence.h"
|
|
|
|
DiscordHandler::DiscordHandler() = default;
|
|
|
|
DiscordHandler::~DiscordHandler()
|
|
{
|
|
Stop();
|
|
}
|
|
|
|
void DiscordHandler::Start()
|
|
{
|
|
m_stop_requested.Set(false);
|
|
m_thread = std::thread(&DiscordHandler::Run, this);
|
|
}
|
|
|
|
void DiscordHandler::Stop()
|
|
{
|
|
m_stop_requested.Set(true);
|
|
|
|
if (m_thread.joinable())
|
|
m_thread.join();
|
|
}
|
|
|
|
void DiscordHandler::DiscordJoin()
|
|
{
|
|
emit DiscordHandler::Join();
|
|
}
|
|
|
|
void DiscordHandler::Run()
|
|
{
|
|
while (!m_stop_requested.IsSet())
|
|
{
|
|
Common::SleepCurrentThread(1000 * 2);
|
|
|
|
Discord::CallPendingCallbacks();
|
|
}
|
|
}
|