2019-11-24 14:20:08 +01:00
|
|
|
#pragma once
|
2021-09-24 19:49:11 +02:00
|
|
|
|
2019-11-24 14:20:08 +01:00
|
|
|
#include "utils/BackgroundThreadWrapper.hpp"
|
|
|
|
#include "utils/logger.h"
|
2022-02-04 14:33:59 +01:00
|
|
|
#include <coreinit/cache.h>
|
2019-11-24 14:20:08 +01:00
|
|
|
|
2022-02-04 14:33:59 +01:00
|
|
|
#define PORT 21
|
2019-11-24 14:20:08 +01:00
|
|
|
|
2021-09-24 19:49:11 +02:00
|
|
|
class BackgroundThread : BackgroundThreadWrapper {
|
2019-11-24 14:20:08 +01:00
|
|
|
public:
|
|
|
|
static BackgroundThread *getInstance() {
|
2021-09-24 19:49:11 +02:00
|
|
|
if (instance == nullptr) {
|
2019-11-24 14:20:08 +01:00
|
|
|
instance = new BackgroundThread();
|
2022-01-30 21:05:09 +01:00
|
|
|
DCFlushRange(&instance, 4);
|
2019-11-24 14:20:08 +01:00
|
|
|
}
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroyInstance() {
|
2021-09-24 19:49:11 +02:00
|
|
|
if (instance != nullptr) {
|
2019-11-24 14:20:08 +01:00
|
|
|
delete instance;
|
2021-09-24 19:49:11 +02:00
|
|
|
instance = nullptr;
|
2022-01-30 21:05:09 +01:00
|
|
|
DCFlushRange(&instance, 4);
|
2019-11-24 14:20:08 +01:00
|
|
|
}
|
|
|
|
}
|
2022-10-06 12:00:52 +02:00
|
|
|
static void destroyInstance(bool forceKill) {
|
|
|
|
if (instance != nullptr) {
|
|
|
|
instance->skipJoin = true;
|
|
|
|
}
|
|
|
|
destroyInstance();
|
|
|
|
}
|
2019-11-24 14:20:08 +01:00
|
|
|
|
|
|
|
BackgroundThread();
|
|
|
|
|
2021-09-24 19:49:11 +02:00
|
|
|
~BackgroundThread() override;
|
2019-11-24 14:20:08 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
static int32_t getPriority() {
|
2022-10-06 18:54:33 +02:00
|
|
|
return 17;
|
2019-11-24 14:20:08 +01:00
|
|
|
}
|
|
|
|
|
2021-09-24 19:49:11 +02:00
|
|
|
BOOL whileLoop() override;
|
2019-11-24 14:20:08 +01:00
|
|
|
|
2021-09-24 19:49:11 +02:00
|
|
|
static BackgroundThread *instance;
|
2019-11-24 14:20:08 +01:00
|
|
|
|
|
|
|
int serverSocket = -1;
|
|
|
|
int network_down = 0;
|
|
|
|
};
|