SkyPortal-plugin/Source/SkyPortal/Private/SkyPortalRunner.cpp

54 lines
1.2 KiB
C++
Raw Normal View History

2024-09-24 22:17:52 +00:00
#include "SkyPortalRunner.h"
2024-09-25 11:47:11 +00:00
FPortalStatusChecker::FPortalStatusChecker(USkyPortalSubsystem* InSubsystem, float InCheckInterval)
: SkyPortalSubsystem(InSubsystem), CheckInterval(InCheckInterval), bShouldRun(true)
{
}
bool FPortalStatusChecker::Init()
{
// Initialization logic, if necessary (e.g., logging)
return true;
}
uint32 FPortalStatusChecker::Run()
{
// Main loop of the thread, runs until Stop() is called
while (bShouldRun)
{
// Check the portal status
CheckPortalStatus();
// Sleep for the specified interval
FPlatformProcess::Sleep(CheckInterval);
}
return 0; // Exit code for the thread
}
void FPortalStatusChecker::Stop()
{
// Signal the thread to stop running
bShouldRun = false;
}
void FPortalStatusChecker::Exit()
{
// Cleanup after the thread has stopped
}
void FPortalStatusChecker::CheckPortalStatus()
{
// Ensure the subsystem is valid
if (SkyPortalSubsystem && SkyPortalSubsystem->bPortalConnected)
{
UE_LOG(LogSkyportalIO, Verbose, TEXT("Check portal"));
// Call the subsystem function to get portal status
SkyPortalSubsystem->CheckComplexResponse();
// Do something with the status (log, notify, etc.)
UE_LOG(LogSkyportalIO, Verbose, TEXT("Portal Status:"));
}
}