54 lines
No EOL
1.2 KiB
C++
54 lines
No EOL
1.2 KiB
C++
#include "SkyPortalRunner.h"
|
|
|
|
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:"));
|
|
}
|
|
} |