Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions Source/FicsitRemoteMonitoring/Private/FRMConfigInitSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
#include "ConfigPropertyString.h"
#include "Engine/Engine.h"

DEFINE_LOG_CATEGORY_STATIC(LogFRMConfigInitSubsystem, Log, All);

void UFRMConfigInitSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
Super::Initialize(Collection);

UConfigManager* ConfigManager = GetGameInstance()->GetSubsystem<UConfigManager>();
if (!ConfigManager)
{
UE_LOG(LogTemp, Error, TEXT("[FRMConfigInitSubsystem] ConfigManager missing."));
UE_LOG(LogFRMConfigInitSubsystem, Error, TEXT("ConfigManager missing."));
return;
}

Expand All @@ -26,11 +28,11 @@ void UFRMConfigInitSubsystem::Initialize(FSubsystemCollectionBase& Collection)
HttpConfig.Authentication_Token = GenerateAuthToken(32);
SaveHttpAuthToken(ConfigManager);

UE_LOG(LogTemp, Log, TEXT("[FRMConfigInitSubsystem] Generated and saved new token: %s"), *HttpConfig.Authentication_Token);
UE_LOG(LogFRMConfigInitSubsystem, Log, TEXT("Generated and saved new token: %s"), *HttpConfig.Authentication_Token);
}
else
{
UE_LOG(LogTemp, Log, TEXT("[FRMConfigInitSubsystem] Token already exists."));
UE_LOG(LogFRMConfigInitSubsystem, Log, TEXT("Token already exists."));
}

AuthenticationToken = HttpConfig.Authentication_Token;
Expand All @@ -43,16 +45,13 @@ void UFRMConfigInitSubsystem::SaveHttpAuthToken(UConfigManager* ConfigManager)
UConfigPropertySection* ConfigurationRootSection = ConfigManager->GetConfigurationRootSection(ConfigId);
if (!ConfigurationRootSection)
{
UE_LOG(LogTemp, Warning, TEXT("[FRMConfigInitSubsystem] ConfigurationRootSection is null."));
UE_LOG(LogFRMConfigInitSubsystem, Warning, TEXT("ConfigurationRootSection is null."));
return;
}

if (ConfigurationRootSection->SectionProperties.Contains("Authentication_Token"))
if (UConfigPropertyString* AuthTokenProperty = Cast<UConfigPropertyString>(ConfigurationRootSection->SectionProperties.FindRef("Authentication_Token")))
{
if (UConfigPropertyString* AuthTokenProperty = Cast<UConfigPropertyString>(ConfigurationRootSection->SectionProperties["Authentication_Token"]))
{
AuthTokenProperty->Value = HttpConfig.Authentication_Token;
}
AuthTokenProperty->Value = HttpConfig.Authentication_Token;
}

ConfigManager->MarkConfigurationDirty(ConfigId);
Expand All @@ -63,7 +62,7 @@ FString UFRMConfigInitSubsystem::GenerateAuthToken(const int32 Length)
const FString Characters = TEXT("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
const int32 CharactersCount = Characters.Len();

FString RandomString;
FString RandomString{};
for (int32 i = 0; i < Length; ++i)
{
RandomString.AppendChar(Characters[FMath::RandRange(0, CharactersCount - 1)]);
Expand Down
6 changes: 3 additions & 3 deletions Source/FicsitRemoteMonitoring/Public/Commands/multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ struct FChatReturn
public:

UPROPERTY(BlueprintReadWrite, Category = "Ficsit Remote Monitoring")
FString Chat;
FString Chat{};

UPROPERTY(BlueprintReadWrite, Category = "Ficsit Remote Monitoring")
FLinearColor Color;
FLinearColor Color{};

UPROPERTY(BlueprintReadWrite, Category = "Ficsit Remote Monitoring")
EExecutionStatus Status;
EExecutionStatus Status{};
};

UCLASS()
Expand Down
8 changes: 4 additions & 4 deletions Source/FicsitRemoteMonitoring/Public/FRMConfigInitSubsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class FICSITREMOTEMONITORING_API UFRMConfigInitSubsystem : public UGameInstanceS
const FConfig_FactoryStruct& GetFactoryConfig() const { return FactoryConfig; }

private:
FString AuthenticationToken;
FString AuthenticationToken{};

FConfig_HTTPStruct HttpConfig;
FConfig_SerialStruct SerialConfig;
FConfig_FactoryStruct FactoryConfig;
FConfig_HTTPStruct HttpConfig{};
FConfig_SerialStruct SerialConfig{};
FConfig_FactoryStruct FactoryConfig{};

FString GenerateAuthToken(int32 Length);
void SaveHttpAuthToken(UConfigManager* ConfigManager);
Expand Down
6 changes: 3 additions & 3 deletions Source/FicsitRemoteMonitoring/Public/FRM_RequestData.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ struct FRequestData
GENERATED_BODY()

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Request Data")
TMap<FString, FString> QueryParams;
TMap<FString, FString> QueryParams{};

bool bIsAuthorized = false;

FString Method = "GET";

TArray<TSharedPtr<FJsonValue>> Body;
TArray<TSharedPtr<FJsonValue>> Body{};

EInterfaceType Interface;
EInterfaceType Interface{};
};
40 changes: 20 additions & 20 deletions Source/FicsitRemoteMonitoring/Public/FicsitRemoteMonitoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ THIRD_PARTY_INCLUDES_END

struct FWebSocketUserData {
// Add any fields here you want to track for each WebSocket client
int32 ClientID;
FString ClientName;
int32 ClientID{};
FString ClientName{};
};

struct FClientInfo
{
FString SubscribedEndpoints; // Keep track of all endpoints that have been subscribed
TArray<uWS::WebSocket<false, true, FWebSocketUserData>*> Client; // Add the third template argument for USERDATA
FString SubscribedEndpoints{}; // Keep track of all endpoints that have been subscribed
TArray<uWS::WebSocket<false, true, FWebSocketUserData>*> Client{}; // Add the third template argument for USERDATA
};

UENUM( BlueprintType )
Expand All @@ -44,7 +44,7 @@ struct FAPIEndpoint {
GENERATED_BODY() // Required for USTRUCT

UPROPERTY()
FString APIName;
FString APIName{};

UPROPERTY()
FString Method = "GET";
Expand All @@ -59,7 +59,7 @@ struct FAPIEndpoint {
bool bRequiresAuthentication = false;

// Function pointer to the endpoint handler (not a UPROPERTY because function pointers aren’t supported by UPROPERTY)
FEndpointFunction FunctionPtr;
FEndpointFunction FunctionPtr{};

FAPIEndpoint(const FString& InMethod = "GET", const FString& InAPIName = "", const FEndpointFunction InFunctionPtr = nullptr)
: APIName(InAPIName),
Expand Down Expand Up @@ -88,8 +88,8 @@ struct FCallEndpointResponse
{
GENERATED_BODY()

TArray<TSharedPtr<FJsonValue>> JsonValues;
bool bUseFirstObject;
TArray<TSharedPtr<FJsonValue>> JsonValues{};
bool bUseFirstObject{};
};

UCLASS()
Expand All @@ -99,13 +99,13 @@ class FICSITREMOTEMONITORING_API AFicsitRemoteMonitoring : public AModSubsystem

private:

TFuture<void> WebServer;
TFuture<void> WebServer{};

bool JSONDebugMode = false;
bool bShouldStop = false;
bool bHasRunningPushDataLoop = false;

FString AuthenticationToken;
FString AuthenticationToken{};

friend class UFGPowerCircuitGroup;

Expand Down Expand Up @@ -155,11 +155,11 @@ class FICSITREMOTEMONITORING_API AFicsitRemoteMonitoring : public AModSubsystem
void ResearchTreeNodeUnlockData_BIE(UFGResearchTreeNode* ResearchTreeNode, TArray<FIntPoint>& Parents, TArray<FIntPoint>& UnhiddenBy, FIntPoint& Coordinates);

// Array of API endpoints
TArray<FAPIEndpoint> APIEndpoints;
TArray<FAPIEndpoint> APIEndpoints{};

TMap<FString, TSet<uWS::WebSocket<false, true, FWebSocketUserData>*>> EndpointSubscribers;
TMap<FString, TSet<uWS::WebSocket<false, true, FWebSocketUserData>*>> EndpointSubscribers{};

TSet<uWS::WebSocket<false, true, FWebSocketUserData>*> ConnectedClients;
TSet<uWS::WebSocket<false, true, FWebSocketUserData>*> ConnectedClients{};

UFUNCTION(BlueprintImplementableEvent, Category = "Ficsit Remote Monitoring")
void InitSerialDevice();
Expand All @@ -183,12 +183,12 @@ class FICSITREMOTEMONITORING_API AFicsitRemoteMonitoring : public AModSubsystem
void AddResponseHeaders(uWS::HttpResponse<false>* res, bool bIncludeContentType);
void AddErrorJson(TArray<TSharedPtr<FJsonValue>>& JsonArray, const FString& ErrorMessage);

TArray<FString> Flavor_Battery;
TArray<FString> Flavor_Doggo;
TArray<FString> Flavor_Player;
TArray<FString> Flavor_Power;
TArray<FString> Flavor_Research;
TArray<FString> Flavor_Train;
TArray<FString> Flavor_Battery{};
TArray<FString> Flavor_Doggo{};
TArray<FString> Flavor_Player{};
TArray<FString> Flavor_Power{};
TArray<FString> Flavor_Research{};
TArray<FString> Flavor_Train{};

protected:
// Called when the game starts or when spawned
Expand All @@ -200,7 +200,7 @@ class FICSITREMOTEMONITORING_API AFicsitRemoteMonitoring : public AModSubsystem
public:

// Store the APIName for later use in the function
FString StoredAPIName;
FString StoredAPIName{};

static void getAll(UObject* WorldContext, FRequestData RequestData, TArray<TSharedPtr<FJsonValue>>& OutJsonArray)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ FFGServerErrorResponse UFRM_Controller::Handler_Frm(FFGFileResponseWrapper& OutF
bool bSuccess = false;
int32 ErrorCode = 200;

/* If this does not build, add `friend class UFRM_Controller;` inside `class FFGRequestHandlerContext` in `FGServerAPIManager.h` */
TSharedPtr<FJsonObject> JsonBody = RequestContext.RequestHandlerContext->RawJsonBody;
TMap<FString, TArray<FString>> RequestHeaders = RequestContext.RequestHandlerContext->RequestHeaders;

Expand Down
6 changes: 3 additions & 3 deletions Source/FicsitRemoteMonitoringServer/Public/FRM_Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class FICSITREMOTEMONITORINGSERVER_API UFRM_Controller : public UFGServerControl
public:

UPROPERTY()
UWorld* World;
UWorld* World{};

UPROPERTY()
AFicsitRemoteMonitoring* ModSubsystem;
AFicsitRemoteMonitoring* ModSubsystem{};

UPROPERTY()
FString AuthToken;
FString AuthToken{};

UFUNCTION( FGServerRequestHandler, FGServerRequestPrivilegeLevel = "NotAuthenticated" )
FFGServerErrorResponse Handler_Frm(FFGFileResponseWrapper& OutFileResponse, const FFGRequestHandlerContextWrapper& RequestContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FICSITREMOTEMONITORINGSERVER_API AFicsitRemoteMonitoringServer : public AM
public:

UPROPERTY()
UFRM_Controller* Controller;
UFRM_Controller* Controller{};

protected:
// Called when the game starts or when spawned
Expand Down