Commit v.2025
This commit is contained in:
5
Config/DefaultDTFluxAPI.ini
Normal file
5
Config/DefaultDTFluxAPI.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[CoreRedirects]
|
||||
+ClassRedirects=(OldName="/Script/DTFluxAPI.DTHttpServerObject",NewName="/Script/DTFluxAPI.DTFluxHttpServerObject")
|
||||
+StructRedirects=(OldName="/Script/DTFluxAPI.DTHttpServerParams",NewName="/Script/DTFluxAPI.DTFluxHttpServerParams")
|
||||
+ClassRedirects=(OldName="/Script/DTFluxAPI.MyClass",NewName="/Script/DTFluxAPI.DTFluxDataStorage")
|
||||
+ClassRedirects=(OldName="/Script/DTFluxCore.DTFluxModelAsset",NewName="/Script/DTFluxCore.DTFluxModel")
|
||||
75
DOCS.md
Normal file
75
DOCS.md
Normal file
@ -0,0 +1,75 @@
|
||||
# DTFluxAPI plugin doc
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
This document describe the usage of the plugin.
|
||||
|
||||
## USAGE
|
||||
### Plugin Project Settings
|
||||
|
||||
#### Race Result API
|
||||
|
||||
- Race Result Port (int) : Port of the Race Result API (Local Server ONLY)
|
||||
- Race Result Url (FString) : Race Result API URL (Local Server ONLY)
|
||||
- Access Is Local (bool) : Race Result API only in local Mode (prevent polling limits)
|
||||
- RaceResultSessionID (FString) : Race result session ID
|
||||
- Start List Access Token (FString) : Token to access Start List endpoint
|
||||
- General Classification Access Token (FString) : Token to access General Classification endpoint
|
||||
- Live Stage Results Access Token (FString) : Token to access Live Stage Results endpoint
|
||||
|
||||
#### Chrono Proxy
|
||||
|
||||
- ProxyAddress
|
||||
- ProxyRootPath
|
||||
- ProxyPort
|
||||
|
||||
#### Server Config
|
||||
|
||||
- InPort (int) : Listening port of the embedded server
|
||||
- Endpoints (FString[] ) : Array of endpoints to be served (Wil be modified in the future)
|
||||
|
||||
#### Objects provided
|
||||
|
||||
- EDTFluxProxyRoute : Routes type for the Proxy
|
||||
- EDTFluxAPIRoute : Routes type for the API Race Result
|
||||
- FSearchFilters : struct that contain a ContestId, a StageId and a gender to filter api searches
|
||||
|
||||
#### Functions provided
|
||||
|
||||
All the function provided by the Project Settings are available both in blueprint and in c++
|
||||
|
||||
- FString GetAPIPath(APIRouteType, FString Filters )
|
||||
- GetAPIPathFiltered(APIRouteType, FSearchFilters Filters )
|
||||
- GetProxyPath( ProxyRouteType, int ContestId, int StageId)
|
||||
|
||||
|
||||
### Model
|
||||
|
||||
### DataStorage
|
||||
|
||||
|
||||
#### Public Data
|
||||
|
||||
##### Collections
|
||||
|
||||
###### Chrono
|
||||
|
||||
- Chrono of each stage (count down)
|
||||
- Current Stage and current contest
|
||||
|
||||
###### Participant
|
||||
|
||||
- Current progression (pourcentage done in stage -> number of checkpoints done)
|
||||
-
|
||||
|
||||
|
||||
|
||||
|
||||
### Subsystem
|
||||
|
||||
|
||||
##### Delegates :
|
||||
|
||||
-
|
||||
|
||||
-
|
||||
50
DTFluxAPI.uplugin
Normal file
50
DTFluxAPI.uplugin
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 1,
|
||||
"VersionName": "1.0",
|
||||
"FriendlyName": "DTFluxAPI",
|
||||
"Description": "DTFlux API plugin",
|
||||
"Category": "Other",
|
||||
"CreatedBy": "Ange-Marie MAURIN",
|
||||
"CreatedByURL": "",
|
||||
"DocsURL": "",
|
||||
"MarketplaceURL": "",
|
||||
"SupportURL": "",
|
||||
"CanContainContent": true,
|
||||
"IsBetaVersion": false,
|
||||
"IsExperimentalVersion": false,
|
||||
"Installed": false,
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "DTFluxCore",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "Default"
|
||||
},
|
||||
{
|
||||
"Name": "DTFluxAssetsEditor",
|
||||
"Type": "Editor",
|
||||
"LoadingPhase": "Default"
|
||||
},
|
||||
{
|
||||
"Name": "DTFluxProjectSettings",
|
||||
"Type": "Editor",
|
||||
"LoadingPhase": "Default"
|
||||
},
|
||||
{
|
||||
"Name": "DTFluxNetwork",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "Default"
|
||||
},
|
||||
{
|
||||
"Name": "DTFluxCoreSubsystem",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "Default"
|
||||
}
|
||||
],
|
||||
"Plugins": [
|
||||
{
|
||||
"Name": "Avalanche",
|
||||
"Enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Icon128.png
Normal file
BIN
Resources/Icon128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
29
Source/DTFluxAssetsEditor/DTFluxAssetsEditor.Build.cs
Normal file
29
Source/DTFluxAssetsEditor/DTFluxAssetsEditor.Build.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class DTFluxAssetsEditor : ModuleRules
|
||||
{
|
||||
public DTFluxAssetsEditor(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
}
|
||||
);
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Slate",
|
||||
"AssetTools",
|
||||
"SlateCore",
|
||||
"UnrealEd",
|
||||
"DTFluxCore",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DTFluxAssetModelTypeActions.h"
|
||||
|
||||
#include "Assets/DTFluxModelAsset.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void FDTFluxAssetModelTypeActions::OpenAssetEditor(const TArray<UObject*>& InObjects,
|
||||
TSharedPtr<IToolkitHost> EditWithinLevelEditor)
|
||||
{
|
||||
FAssetTypeActions_Base::OpenAssetEditor(InObjects, EditWithinLevelEditor);
|
||||
}
|
||||
|
||||
UClass* FDTFluxAssetModelTypeActions::GetSupportedClass() const
|
||||
{
|
||||
return UDTFluxModelAsset::StaticClass();
|
||||
}
|
||||
|
||||
FText FDTFluxAssetModelTypeActions::GetName() const
|
||||
{
|
||||
return INVTEXT("DTFlux Model");
|
||||
}
|
||||
|
||||
FColor FDTFluxAssetModelTypeActions::GetTypeColor() const
|
||||
{
|
||||
return FColor(231, 81, 67);
|
||||
}
|
||||
|
||||
uint32 FDTFluxAssetModelTypeActions::GetCategories()
|
||||
{
|
||||
return Category;
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
#include "DTFluxAssetsEditorModule.h"
|
||||
#include "IAssetTools.h"
|
||||
#include "DTFluxAssetModelTypeActions.h"
|
||||
#include "IAssetTools.h"
|
||||
#include "AssetToolsModule.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDTFluxAssetsEditorModule"
|
||||
|
||||
|
||||
DTFLUXASSETSEDITOR_API DEFINE_LOG_CATEGORY(logDTFluxAssetEditor)
|
||||
void FDTFluxAssetsEditorModule::StartupModule()
|
||||
{
|
||||
IAssetTools& AssetToolsModule = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools").Get();
|
||||
EAssetTypeCategories::Type Category = AssetToolsModule.RegisterAdvancedAssetCategory("DTFlux", INVTEXT("DTFlux"));
|
||||
DTFluxAssetModelActions = MakeShareable(new FDTFluxAssetModelTypeActions(Category));
|
||||
AssetToolsModule.RegisterAssetTypeActions(DTFluxAssetModelActions.ToSharedRef());
|
||||
}
|
||||
|
||||
void FDTFluxAssetsEditorModule::ShutdownModule()
|
||||
{
|
||||
if(DTFluxAssetModelActions.IsValid() && FModuleManager::Get().IsModuleLoaded("AssetTools"))
|
||||
{
|
||||
IAssetTools& AssetToolsModule = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools").Get();
|
||||
AssetToolsModule.UnregisterAssetTypeActions(DTFluxAssetModelActions.ToSharedRef());
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDTFluxAssetsEditorModule, DTFluxAssetsEditor)
|
||||
@ -0,0 +1,24 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DTFluxModelAssetFactory.h"
|
||||
|
||||
#include "Assets/DTFluxModelAsset.h"
|
||||
|
||||
|
||||
|
||||
UDTFluxModelAssetFactory::UDTFluxModelAssetFactory(const FObjectInitializer& ObjectInitializer)
|
||||
{
|
||||
SupportedClass = UDTFluxModelAsset::StaticClass();
|
||||
}
|
||||
|
||||
bool UDTFluxModelAssetFactory::CanCreateNew() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
UObject* UDTFluxModelAssetFactory::FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName,
|
||||
EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
|
||||
{
|
||||
return NewObject<UDTFluxModelAsset>(InParent, InName, Flags);
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AssetTypeActions_Base.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DTFLUXASSETSEDITOR_API FDTFluxAssetModelTypeActions : public FAssetTypeActions_Base
|
||||
{
|
||||
public:
|
||||
FDTFluxAssetModelTypeActions(EAssetTypeCategories::Type InCategory): Category(InCategory){};
|
||||
public:
|
||||
UClass* GetSupportedClass() const override;
|
||||
FText GetName() const override;
|
||||
FColor GetTypeColor() const override;
|
||||
uint32 GetCategories() override;
|
||||
virtual void OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<IToolkitHost> EditWithinLevelEditor = TSharedPtr<IToolkitHost>()) override;
|
||||
|
||||
private:
|
||||
EAssetTypeCategories::Type Category;
|
||||
};
|
||||
29
Source/DTFluxAssetsEditor/Public/DTFluxAssetsEditorModule.h
Normal file
29
Source/DTFluxAssetsEditor/Public/DTFluxAssetsEditorModule.h
Normal file
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
|
||||
/**
|
||||
* @module DTFluxAssetsEditorModule
|
||||
* @details DTFlux Project is a framework to integrate all kind of events data from
|
||||
* multiple API (stopwatch servers, etc...) or manually to unreal motion design platform
|
||||
* to create live audiovisual shows.
|
||||
* @brief This module provides all editor and ui tools.
|
||||
* @license See LICENSE.TXT at the of DTFluxAPI plugin folder or at
|
||||
* @see https://github.com/A2MSystemes/DTFluxAPI/blob/main/LICENSE
|
||||
* @author Ange-Marie MAURIN
|
||||
*/
|
||||
|
||||
class FDTFluxAssetModelTypeActions;
|
||||
DTFLUXASSETSEDITOR_API DECLARE_LOG_CATEGORY_EXTERN(logDTFluxAssetEditor, Log, All);
|
||||
|
||||
class FDTFluxAssetsEditorModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
private:
|
||||
TSharedPtr<FDTFluxAssetModelTypeActions> DTFluxAssetModelActions = nullptr;
|
||||
};
|
||||
20
Source/DTFluxAssetsEditor/Public/DTFluxModelAssetFactory.h
Normal file
20
Source/DTFluxAssetsEditor/Public/DTFluxModelAssetFactory.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxModelAssetFactory.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DTFLUXASSETSEDITOR_API UDTFluxModelAssetFactory : public UFactory
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UDTFluxModelAssetFactory(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
virtual UObject* FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
|
||||
virtual bool CanCreateNew() const override;
|
||||
};
|
||||
29
Source/DTFluxCore/DTFluxCore.Build.cs
Normal file
29
Source/DTFluxCore/DTFluxCore.Build.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class DTFluxCore : ModuleRules
|
||||
{
|
||||
public DTFluxCore(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
}
|
||||
);
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
"DTFluxCore",
|
||||
"DTFluxProjectSettings",
|
||||
"DTFluxNetwork"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
4
Source/DTFluxCore/Private/Assets/DTFluxModelAsset.cpp
Normal file
4
Source/DTFluxCore/Private/Assets/DTFluxModelAsset.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Assets/DTFluxModelAsset.h"
|
||||
19
Source/DTFluxCore/Private/DTFluxCoreModule.cpp
Normal file
19
Source/DTFluxCore/Private/DTFluxCoreModule.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "DTFluxCoreModule.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDTFluxCoreModule"
|
||||
|
||||
DTFLUXCORE_API DEFINE_LOG_CATEGORY(logDTFluxCore);
|
||||
|
||||
void FDTFluxCoreModule::StartupModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FDTFluxCoreModule::ShutdownModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDTFluxCoreModule, DTFluxCore)
|
||||
11
Source/DTFluxCore/Private/Types/DTFluxCoreEnums.h
Normal file
11
Source/DTFluxCore/Private/Types/DTFluxCoreEnums.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxCoreEnums.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EDTFluxConnectionStatus : uint8
|
||||
{
|
||||
Unset = 0 UMETA(DisplayName="Unset"),
|
||||
Connected = 1 << 0 UMETA(DisplayName="Connected"),
|
||||
Error = 2 << 1 UMETA(DisplayName="Error")
|
||||
};
|
||||
@ -0,0 +1,7 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Types/Interfaces/DTFluxDataPoller.h"
|
||||
|
||||
|
||||
// Add default functionality here for any IDTFluxDataPoller functions that are not pure virtual.
|
||||
27
Source/DTFluxCore/Public/Assets/DTFluxModelAsset.h
Normal file
27
Source/DTFluxCore/Public/Assets/DTFluxModelAsset.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "DTFluxModelAsset.generated.h"
|
||||
|
||||
class UDTFluxContest;
|
||||
class UDTFluxPerson;
|
||||
/**
|
||||
* Class representing Data Storage
|
||||
*/
|
||||
UCLASS(BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxModelAsset : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Storage")
|
||||
TArray<UDTFluxPerson*> Persons;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Storage")
|
||||
TArray<UDTFluxContest*> Contest;
|
||||
|
||||
};
|
||||
25
Source/DTFluxCore/Public/DTFluxCoreModule.h
Normal file
25
Source/DTFluxCore/Public/DTFluxCoreModule.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
/**
|
||||
* @module DTFluxCoreModule
|
||||
* @details DTFlux Project is a framework to integrate all kind of events data from
|
||||
* multiple API (stopwatch servers, etc...) or manually to unreal motion design platform
|
||||
* to create live audiovisual shows.
|
||||
* @brief This module provides all necessary basic class to set up your communication
|
||||
* between an external APIs and unreal engine.
|
||||
* @license See LICENSE.TXT at the of DTFluxAPI plugin folder or at
|
||||
* @see https://github.com/A2MSystemes/DTFluxAPI/blob/main/LICENSE
|
||||
* @author Ange-Marie MAURIN
|
||||
*/
|
||||
|
||||
DTFLUXCORE_API DECLARE_LOG_CATEGORY_EXTERN(logDTFluxCore, Log, All);
|
||||
|
||||
class FDTFluxCoreModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
||||
20
Source/DTFluxCore/Public/Types/DTFluxModelEnums.h
Normal file
20
Source/DTFluxCore/Public/Types/DTFluxModelEnums.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxModelEnums.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UENUM(BlueprintType, Category="DTFlux|Model")
|
||||
enum class EDTFluxParticipantStatusType : uint8
|
||||
{
|
||||
Normal = 0 UMETA(DisplayName="Normal"),
|
||||
OutOfRace = 1 UMETA(DisplayName="HorsCourse"),
|
||||
DSQ = 2 UMETA(DisplayName="Disqualifié"),
|
||||
DNF = 3 UMETA(DisplayName="Abandon"),
|
||||
DNS = 4 UMETA(DisplayName="NonPartant"),
|
||||
NotLinedUp = 5 UMETA(DisplayName="NonPresentAuDépart"),
|
||||
};
|
||||
25
Source/DTFluxCore/Public/Types/Interfaces/DTFluxData.h
Normal file
25
Source/DTFluxCore/Public/Types/Interfaces/DTFluxData.h
Normal file
@ -0,0 +1,25 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxData.generated.h"
|
||||
|
||||
/**
|
||||
* @brief Structure that represent Basic Data
|
||||
*/
|
||||
UCLASS(BlueprintType, Blueprintable)
|
||||
class DTFLUXCORE_API UDTFluxData: public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UDTFluxData(){};
|
||||
~UDTFluxData(){};
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FName RequestId;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FDateTime ReceivedAt = FDateTime::Now();
|
||||
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxResponse.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "DTFluxDataCollector.generated.h"
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE()
|
||||
class UDTFluxDataCollector : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class IDTFluxDataCollector
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnDataReceived, FDTFluxResponse, Response);
|
||||
virtual FOnDataReceived& OnReceivedData()=0;
|
||||
|
||||
virtual void ParseData(const FString& InData) = 0;
|
||||
virtual TSubclassOf<UDTFluxData> GetData() = 0;
|
||||
|
||||
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
||||
public:
|
||||
};
|
||||
40
Source/DTFluxCore/Public/Types/Interfaces/DTFluxDataPoller.h
Normal file
40
Source/DTFluxCore/Public/Types/Interfaces/DTFluxDataPoller.h
Normal file
@ -0,0 +1,40 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxData.h"
|
||||
#include "DTFluxDataCollector.h"
|
||||
#include "DTFluxRequest.h"
|
||||
#include "DTFluxResponse.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "DTFluxDataPoller.generated.h"
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE(BlueprintType, Blueprintable)
|
||||
class UDTFluxDataCollectorPoller : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Interface for Data collector that can Poll for Data from datasource
|
||||
*/
|
||||
class IDTFluxDataCollectorPoller : public IDTFluxDataCollector
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnBeforePolling, FDTFluxRequest&, FutureRequest);
|
||||
virtual FOnBeforePolling& OnBeforePolling() = 0 ;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAfterRequestSent, const FName, RequestId);
|
||||
virtual FOnAfterRequestSent& OnAfterRequestSent() = 0;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAfterPolling, const FDTFluxRequest&, FutureRequest);
|
||||
virtual FOnAfterPolling& OnAfterPolling()=0;
|
||||
|
||||
};
|
||||
31
Source/DTFluxCore/Public/Types/Interfaces/DTFluxRequest.h
Normal file
31
Source/DTFluxCore/Public/Types/Interfaces/DTFluxRequest.h
Normal file
@ -0,0 +1,31 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxRequest.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
USTRUCT(BlueprintType, Blueprintable)
|
||||
struct DTFLUXCORE_API FDTFluxRequest
|
||||
{
|
||||
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
FDTFluxRequest()
|
||||
{
|
||||
RequestId = FName("DefautRequestId");
|
||||
RequestBody = FString();
|
||||
RequestedAt = FDateTime::Now();
|
||||
};
|
||||
~FDTFluxRequest(){};
|
||||
|
||||
UPROPERTY(BlueprintReadWrite);
|
||||
FName RequestId;
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FString RequestBody;
|
||||
UPROPERTY(BlueprintReadOnly);
|
||||
FDateTime RequestedAt;
|
||||
};
|
||||
34
Source/DTFluxCore/Public/Types/Interfaces/DTFluxResponse.h
Normal file
34
Source/DTFluxCore/Public/Types/Interfaces/DTFluxResponse.h
Normal file
@ -0,0 +1,34 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxData.h"
|
||||
#include "DTFluxResponse.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
USTRUCT(BlueprintType, Blueprintable)
|
||||
struct DTFLUXCORE_API FDTFluxResponse
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
FDTFluxResponse()
|
||||
{
|
||||
RequestId = FName("DefaultRequestId");
|
||||
ReceivedAt = FDateTime::Now();
|
||||
Data = nullptr;
|
||||
};
|
||||
~FDTFluxResponse(){};
|
||||
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FName RequestId;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FDateTime ReceivedAt;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
UDTFluxData* Data;
|
||||
|
||||
};
|
||||
175
Source/DTFluxCore/Public/Types/UDTFluxDataModel.h
Normal file
175
Source/DTFluxCore/Public/Types/UDTFluxDataModel.h
Normal file
@ -0,0 +1,175 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "DTFluxModelEnums.h"
|
||||
#include "UDTFluxDataModel.generated.h"
|
||||
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType, Category="DTFlux|Model")
|
||||
class DTFLUXCORE_API UDTFluxPerson : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
FString FirstName;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
FString LastName;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
FString Gender;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
FString FunctionLine1 = TEXT("");
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
FString FunctionLine2 = TEXT("");
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Blueprintable, BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxParticipant : public UDTFluxPerson
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
FString Category;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
FString Club;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
bool Elite;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Blueprintable, BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxTeam : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
int Bib;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
UDTFluxParticipant* Participant1;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
UDTFluxParticipant* Participant2;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
EDTFluxParticipantStatusType Status;
|
||||
};
|
||||
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxRankingBase : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
int Bib;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
int Ranking;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
FString Time;
|
||||
};
|
||||
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxContestRanking : public UDTFluxRankingBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
int ContestId;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
FString Gap;
|
||||
};
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxStageRanking : public UDTFluxContestRanking
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
int StageId;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
FString TimeSwim;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
FString TimeTransition;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
FString TimeRun;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
FDateTime TimeStart;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
float SpeedRunning;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
float SpeedTotal;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
float SpeedSwim;
|
||||
};
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxSplitRanking : public UDTFluxStageRanking
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
int SplitId;
|
||||
};
|
||||
|
||||
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxEvent : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
int Id;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
FString Name;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
FDateTime StartTime;
|
||||
};
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxSplit : public UDTFluxEvent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
TArray<UDTFluxSplitRanking*> SplitRankings;
|
||||
};
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxStage : public UDTFluxEvent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
TArray<UDTFluxSplit*> Splits;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
TArray<UDTFluxStageRanking*> StageRankings;
|
||||
};
|
||||
|
||||
UCLASS(Blueprintable, BlueprintType)
|
||||
class DTFLUXCORE_API UDTFluxContest : public UDTFluxEvent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
int ContestID;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
TArray<UDTFluxContestRanking*> ContestRankings;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
TArray<UDTFluxStage*> Stages;
|
||||
};
|
||||
|
||||
29
Source/DTFluxCoreSubsystem/DTFluxCoreSubsystem.Build.cs
Normal file
29
Source/DTFluxCoreSubsystem/DTFluxCoreSubsystem.Build.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class DTFluxCoreSubsystem : ModuleRules
|
||||
{
|
||||
public DTFluxCoreSubsystem(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
}
|
||||
);
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
"DTFluxNetwork",
|
||||
"DTFluxProjectSettings",
|
||||
"DTFluxCore"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
17
Source/DTFluxCoreSubsystem/Private/DTFluxCoreSubsystem.cpp
Normal file
17
Source/DTFluxCoreSubsystem/Private/DTFluxCoreSubsystem.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DTFluxCoreSubsystem.h"
|
||||
|
||||
#include "Subsystems//DTFluxNetworkSubsystem.h"
|
||||
|
||||
void UDTFluxCoreSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
Super::Initialize(Collection);
|
||||
NetworkSubsystem = GEngine->GetEngineSubsystem<UFDTFluxNetworkSubsystem>();
|
||||
}
|
||||
|
||||
void UDTFluxCoreSubsystem::Deinitialize()
|
||||
{
|
||||
Super::Deinitialize();
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
#include "DTFluxCoreSubsystemModule.h"
|
||||
|
||||
DTFLUXCORESUBSYSTEM_API DEFINE_LOG_CATEGORY(logDTFluxCoreSubsystem)
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDTFluxCoreSubsystemModule"
|
||||
|
||||
void FDTFluxCoreSubsystemModule::StartupModule()
|
||||
{
|
||||
}
|
||||
|
||||
void FDTFluxCoreSubsystemModule::ShutdownModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDTFluxCoreSubsystemModule, DTFluxCoreSubsystem)
|
||||
46
Source/DTFluxCoreSubsystem/Public/DTFluxCoreSubsystem.h
Normal file
46
Source/DTFluxCoreSubsystem/Public/DTFluxCoreSubsystem.h
Normal file
@ -0,0 +1,46 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Subsystems/EngineSubsystem.h"
|
||||
#include "Types/Interfaces/DTFluxDataCollector.h"
|
||||
#include "DTFluxCoreSubsystem.generated.h"
|
||||
|
||||
class UFDTFluxNetworkSubsystem;
|
||||
/** Forward Decl */
|
||||
class UDTFluxModelAsset;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DTFLUXCORESUBSYSTEM_API UDTFluxCoreSubsystem : public UEngineSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
public:
|
||||
TSoftObjectPtr<UDTFluxModelAsset> DataStorage;
|
||||
|
||||
// TSharedPtr<FDTFluxParser> Parser;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnSplitRankings, FDateTime, ReceivedAt, TArray<UDTFluxSplitRanking*>, SplitRankings)
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnStageRankings, FDateTime, ReceivedAt, TArray<UDTFluxStageRanking*>, StageRankings)
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnContestRankings, FDateTime, ReceivedAt, TArray<UDTFluxContestRanking*>, StageRankings)
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnTeamList, FDateTime, ReceivedAt, TArray<UDTFluxTeam*>, TeamList)
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnTeamUpdate, FDateTime, ReceivedAt, TArray<UDTFluxTeam*>, TeamUpdatedList)
|
||||
|
||||
|
||||
protected:
|
||||
// ~Subsystem Interface
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
virtual void Deinitialize() override;
|
||||
// ~Subsystem Interface
|
||||
private:
|
||||
UFDTFluxNetworkSubsystem* NetworkSubsystem = nullptr;
|
||||
};
|
||||
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
DTFLUXCORESUBSYSTEM_API DECLARE_LOG_CATEGORY_EXTERN(logDTFluxCoreSubsystem, All, All);
|
||||
|
||||
class DTFLUXCORESUBSYSTEM_API FDTFluxCoreSubsystemModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
||||
30
Source/DTFluxNetwork/DTFluxNetwork.Build.cs
Normal file
30
Source/DTFluxNetwork/DTFluxNetwork.Build.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class DTFluxNetwork : ModuleRules
|
||||
{
|
||||
public DTFluxNetwork(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
}
|
||||
);
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
"WebSockets",
|
||||
"HTTP",
|
||||
"DTFluxCore",
|
||||
"DTFluxProjectSettings",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
13
Source/DTFluxNetwork/Private/Clients/DTFluxHttpClient.cpp
Normal file
13
Source/DTFluxNetwork/Private/Clients/DTFluxHttpClient.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Clients/DTFluxHttpClient.h"
|
||||
|
||||
|
||||
FDTFluxHttpClient::FDTFluxHttpClient()
|
||||
{
|
||||
}
|
||||
|
||||
FDTFluxHttpClient::~FDTFluxHttpClient()
|
||||
{
|
||||
}
|
||||
141
Source/DTFluxNetwork/Private/Clients/DTFluxWebSocketClient.cpp
Normal file
141
Source/DTFluxNetwork/Private/Clients/DTFluxWebSocketClient.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Clients/DTFluxWebSocketClient.h"
|
||||
|
||||
#include "DTFluxNetworkModule.h"
|
||||
#include "IWebSocket.h"
|
||||
#include "WebSocketsModule.h"
|
||||
#include "Utils/WebSocketStatusCode.h"
|
||||
|
||||
int32 FDTFluxWebSocketClient::LastId = 0;
|
||||
FName FDTFluxWebSocketClient::DefaultId = FName("DTFluxWsClient");
|
||||
|
||||
FDTFluxWebSocketClient::FDTFluxWebSocketClient()
|
||||
{
|
||||
ClientId = FName("DTFluxWsClient_" + FDTFluxWebSocketClient::LastId);
|
||||
FDTFluxWebSocketClient::LastId++;
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::Connect()
|
||||
{
|
||||
Ws = FWebSocketsModule::Get().CreateWebSocket(WsAddress);
|
||||
if(Ws.IsValid())
|
||||
{
|
||||
Bind_Internal();
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Connecting"))
|
||||
Ws->Connect();
|
||||
}
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::Reconnect()
|
||||
{
|
||||
if(Ws.IsValid())
|
||||
{
|
||||
if(Ws->IsConnected())
|
||||
{
|
||||
Ws->Close();
|
||||
Ws->Connect();
|
||||
return;
|
||||
}
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Connecting"))
|
||||
Ws->Connect();
|
||||
return;
|
||||
}
|
||||
UE_LOG(logDTFluxNetwork, Error, TEXT("Undelying IWebSocket is Invalid, Cannot Connect !!!"))
|
||||
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::Disconnect()
|
||||
{
|
||||
if(Ws.IsValid())
|
||||
{
|
||||
if(Ws->IsConnected())
|
||||
{
|
||||
EWebSocketCloseCode ReasonCode = EWebSocketCloseCode::Normal;
|
||||
Ws->Close(static_cast<int32>(ReasonCode), FString("Normal Disconnect, BYE !!!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FDTFluxWsClientError FDTFluxWebSocketClient::GetError()
|
||||
{
|
||||
FDTFluxWsClientError Error;
|
||||
if(Errors.Num() > 0)
|
||||
{
|
||||
return Errors.Pop(EAllowShrinking::Yes);
|
||||
}
|
||||
return FDTFluxWsClientError::CreateNoError(ClientId);
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::ClearErrors()
|
||||
{
|
||||
Errors.Empty();
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::AddError(const FDTFluxWsClientError Error)
|
||||
{
|
||||
Errors.Add(Error);
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::Send(const FString& Message) const
|
||||
{
|
||||
Ws->Send(Message);
|
||||
}
|
||||
|
||||
|
||||
void FDTFluxWebSocketClient::Bind_Internal()
|
||||
{
|
||||
Ws->OnConnected().AddRaw(this, &FDTFluxWebSocketClient::OnConnected_Internal);
|
||||
Ws->OnClosed().AddRaw(this, &FDTFluxWebSocketClient::OnClientClosed_Internal);
|
||||
Ws->OnConnectionError().AddRaw(this, &FDTFluxWebSocketClient::OnClientError_Internal);
|
||||
Ws->OnMessage().AddRaw(this, &FDTFluxWebSocketClient::OnClientReceiveMessage_Internal);
|
||||
Ws->OnBinaryMessage().AddRaw(this, &FDTFluxWebSocketClient::OnClientReceiveBinaryMessage_Internal);
|
||||
Ws->OnMessageSent().AddRaw(this, &FDTFluxWebSocketClient::OnMessageSent_Internal);
|
||||
Ws->OnRawMessage().AddRaw(this, &FDTFluxWebSocketClient::OnClientReceiveRawMessage_Internal);
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::OnConnected_Internal()
|
||||
{
|
||||
DTFluxWsClientConnectedEvent.Broadcast();
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::OnClientClosed_Internal(int32 StatusCode, const FString& Reason, bool bWasClean)
|
||||
{
|
||||
DTFluxWsClientClosedEvent.Broadcast(StatusCode, Reason, bWasClean);
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::OnClientError_Internal(const FString& ErrorMessage)
|
||||
{
|
||||
DTFluxWsClientConnectionErrorEvent.Broadcast(ErrorMessage);
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::OnClientReceiveMessage_Internal(const FString& Message)
|
||||
{
|
||||
DTFluxWsClientMessageEvent.Broadcast(Message);
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::OnClientReceiveBinaryMessage_Internal(const void* Data, SIZE_T Size, bool bIsLastFragment)
|
||||
{
|
||||
DTFluxWsClientBinaryMessageEvent.Broadcast(Data,Size, bIsLastFragment);
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::OnClientReceiveRawMessage_Internal(const void* Data, SIZE_T Size, SIZE_T BytesRemaining)
|
||||
{
|
||||
DTFluxWsClientRawMessageEvent.Broadcast(Data, Size, BytesRemaining);
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::OnMessageSent_Internal(const FString& MessageString)
|
||||
{
|
||||
DTFluxWsClientMessageSentEvent.Broadcast(MessageString);
|
||||
}
|
||||
|
||||
void FDTFluxWebSocketClient::SendMessage_internal(const FString& Message)
|
||||
{
|
||||
if(Ws.IsValid() && Ws->IsConnected())
|
||||
{
|
||||
Ws->Send(Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
19
Source/DTFluxNetwork/Private/DTFluxNetworkModule.cpp
Normal file
19
Source/DTFluxNetwork/Private/DTFluxNetworkModule.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "DTFluxNetworkModule.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDTFluxNetworkModule"
|
||||
|
||||
DTFLUXNETWORK_API DEFINE_LOG_CATEGORY(logDTFluxNetwork);
|
||||
|
||||
void FDTFluxNetworkModule::StartupModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FDTFluxNetworkModule::ShutdownModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDTFluxNetworkModule, DTFluxNetwork)
|
||||
@ -0,0 +1,176 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Subsystems/DTFluxNetworkSubsystem.h"
|
||||
|
||||
#include "DTFluxCoreModule.h"
|
||||
#include "DTFluxNetworkModule.h"
|
||||
#include "DTFluxNetworkSettings.h"
|
||||
#include "Clients/DTFluxHttpClient.h"
|
||||
#include "Clients/DTFluxWebSocketClient.h"
|
||||
|
||||
|
||||
void UFDTFluxNetworkSubsystem::Connect()
|
||||
{
|
||||
WsClient->SetAddress(ConstructWsAddress(WsSettings.Address, WsSettings.Path, WsSettings.Port));
|
||||
WsClient->Connect();
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
Super::Initialize(Collection);
|
||||
FDTFluxCoreModule& DTFluxCore = FModuleManager::Get().LoadModuleChecked<FDTFluxCoreModule>("DTFluxCore");
|
||||
FString StatusString = UEnum::GetValueAsString(WsStatus);
|
||||
UE_LOG(logDTFluxNetwork, Log, TEXT("Status is %s"), *StatusString);
|
||||
UDTFluxNetworkSettings* NetworkSettings = GetMutableDefault<UDTFluxNetworkSettings>();
|
||||
UDTFluxNetworkSettings::GetWebSocketSettings(NetworkSettings, WsSettings);
|
||||
UDTFluxNetworkSettings::GetHTTPSettings(NetworkSettings, HttpSettings);
|
||||
WsClient = MakeShareable<FDTFluxWebSocketClient>(new FDTFluxWebSocketClient());
|
||||
HttpClient = MakeShareable<FDTFluxHttpClient>(new FDTFluxHttpClient());
|
||||
RegisterWebSocketEvents();
|
||||
RegisterHttpEvents();
|
||||
#if WITH_EDITOR
|
||||
NetworkSettings->OnDTFluxWebSocketSettingsChanged.AddUFunction(this, FName("WsSettingsChanged"));
|
||||
NetworkSettings->OnDTFluxHttpSettingsChanged.AddUFunction(this, FName("HttpSettingsChanged"));
|
||||
#endif
|
||||
if(WsSettings.bShouldConnectAtStartup)
|
||||
{
|
||||
WsClient->SetAddress(ConstructWsAddress(WsSettings.Address, WsSettings.Path, WsSettings.Port));
|
||||
WsClient->Connect();
|
||||
}
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::Deinitialize()
|
||||
{
|
||||
Super::Deinitialize();
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::WsSettingsChanged(const FDTFluxWsSettings& NewWsSettings)
|
||||
{
|
||||
// TODO Implement a ClientSelector To retrieve impacted WsClients and populate changes or maybe create a delegate
|
||||
bool bNeedsReload = WsSettings != NewWsSettings;
|
||||
|
||||
WsSettings = NewWsSettings;
|
||||
// UE_LOG(logDTFluxNetwork, Warning, TEXT("WSocket Settings Changed \n\t Address : %s Path : %s Port : %i\n\tbShouldConnectAtStatup : %s, bShouldAutoReconnectOnClosed %s, bShouldAutoReconnectOnError %s"),
|
||||
// *NewWsSettings.Address, *NewWsSettings.Path, NewWsSettings.Port,
|
||||
// NewWsSettings.bShouldConnectAtStartup ? TEXT("True") : TEXT("False"),
|
||||
// NewWsSettings.bShouldAutoReconnectOnClosed ? TEXT("True") : TEXT("False"),
|
||||
// NewWsSettings.bShouldAutoReconnectOnError ? TEXT("True") : TEXT("False") );
|
||||
if( bNeedsReload || WsSettings.bShouldConnectAtStartup)
|
||||
{
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("WSocket Settings needs Reloding client"))
|
||||
ReconnectWs(FName("Ws_Client_0"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UFDTFluxNetworkSubsystem::HttpSettingsChanged(const FDTFluxHttpSettings& NewHttpSettings)
|
||||
{
|
||||
// TODO Implement a ClientSelector To retrieve impacted HttpClients and populate changes or maybe create a delegate
|
||||
HttpSettings = NewHttpSettings;
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::ReconnectWs(const FName WsClientId)
|
||||
{
|
||||
FString NewAddress = ConstructWsAddress(WsSettings.Address, WsSettings.Path, WsSettings.Port);
|
||||
WsClient->SetAddress(NewAddress);
|
||||
WsClient->Reconnect();
|
||||
}
|
||||
void UFDTFluxNetworkSubsystem::ReconnectHttp(const FName WsClientId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::RegisterWebSocketEvents()
|
||||
{
|
||||
OnWsConnectedEventDelegateHandle =
|
||||
WsClient->RegisterConnectedEvent().AddUObject(this, &UFDTFluxNetworkSubsystem::OnWebSocketConnected_Subsystem);
|
||||
OnWsConnectionErrorEventDelegateHandle =
|
||||
WsClient->RegisterConnectionError()
|
||||
.AddUObject(this, &UFDTFluxNetworkSubsystem::OnWebSocketConnectionError_Subsystem);
|
||||
OnWsClosedEventDelegateHandle =
|
||||
WsClient->RegisterClosedEvent()
|
||||
.AddUObject(this, &UFDTFluxNetworkSubsystem::OnWebSocketClosedEvent_Subsystem);
|
||||
OnWsMessageEventDelegateHandle =
|
||||
WsClient->RegisterMessageEvent()
|
||||
.AddUObject(this, &UFDTFluxNetworkSubsystem::OnWebSocketMessageEvent_Subsystem);
|
||||
OnWsMessageSentEventDelegateHandle =
|
||||
WsClient->RegisterMessageSentEvent()
|
||||
.AddUObject(this, &UFDTFluxNetworkSubsystem::OnWebSocketMessageSentEvent_Subsystem);
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::RegisterHttpEvents()
|
||||
{
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::UnregisterWebSocketEvents()
|
||||
{
|
||||
if(OnWsConnectedEventDelegateHandle.IsValid())
|
||||
{
|
||||
WsClient->UnregisterConnectedEvent().Remove(OnWsConnectedEventDelegateHandle);
|
||||
}
|
||||
if(OnWsConnectionErrorEventDelegateHandle.IsValid())
|
||||
{
|
||||
WsClient->UnregisterConnectionError();
|
||||
}
|
||||
if(OnWsClosedEventDelegateHandle.IsValid())
|
||||
{
|
||||
WsClient->UnregisterClosedEvent();
|
||||
}
|
||||
if(OnWsMessageEventDelegateHandle.IsValid())
|
||||
{
|
||||
WsClient->UnregisterMessageEvent();
|
||||
}
|
||||
if(OnWsMessageSentEventDelegateHandle.IsValid())
|
||||
{
|
||||
WsClient->UnregisterRawMessageEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::UnregisterHttpEvents()
|
||||
{
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::OnWebSocketConnected_Subsystem()
|
||||
{
|
||||
OnWebSocketConnected.Broadcast();
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws Is Connected with %s"), *WsClient->GetAddress())
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::OnWebSocketConnectionError_Subsystem(const FString& Error)
|
||||
{
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws Error with %s : %s"), *WsClient->GetAddress(), *Error);
|
||||
if(WsSettings.bShouldAutoReconnectOnError)
|
||||
{
|
||||
WsClient->Reconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::OnWebSocketClosedEvent_Subsystem(int32 StatusCode, const FString& Reason, bool bWasClean)
|
||||
{
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws Error with %s :\n Reason : %s \tStatusCode : %i, bWasClean : %s"),
|
||||
*WsClient->GetAddress(), *Reason, StatusCode, bWasClean ? TEXT("True") : TEXT("False"));
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::OnWebSocketMessageEvent_Subsystem(const FString& MessageString)
|
||||
{
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws %s :\nMessage Received : %s"), *WsClient->GetAddress(), *MessageString);
|
||||
//Do Something With the message
|
||||
|
||||
}
|
||||
|
||||
void UFDTFluxNetworkSubsystem::OnWebSocketMessageSentEvent_Subsystem(const FString& MessageSent)
|
||||
{
|
||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws %s :\nMessage Sent: %s"), *WsClient->GetAddress(), *MessageSent);
|
||||
}
|
||||
|
||||
FString UFDTFluxNetworkSubsystem::ConstructWsAddress(const FString& Address, const FString& Path, const int& Port)
|
||||
{
|
||||
FString NewAddress;
|
||||
if( !Address.Contains("ws://") && !Address.Contains("wss://"))
|
||||
{
|
||||
NewAddress += FString("ws://");
|
||||
}
|
||||
NewAddress +=Address + FString(":") + FString::FromInt(Port) + Path;
|
||||
return NewAddress;
|
||||
// UE_LOG(logDTFluxNetwork, Log, TEXT("NewAddress : %s"), *NewAddress);
|
||||
}
|
||||
18
Source/DTFluxNetwork/Public/Clients/DTFluxHttpClient.h
Normal file
18
Source/DTFluxNetwork/Public/Clients/DTFluxHttpClient.h
Normal file
@ -0,0 +1,18 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "HttpModule.h"
|
||||
#include "Interfaces/IHttpRequest.h"
|
||||
#include "Interfaces/IHttpResponse.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DTFLUXNETWORK_API FDTFluxHttpClient: public TSharedFromThis<FDTFluxHttpClient>
|
||||
{
|
||||
public:
|
||||
FDTFluxHttpClient();
|
||||
~FDTFluxHttpClient();
|
||||
};
|
||||
185
Source/DTFluxNetwork/Public/Clients/DTFluxWebSocketClient.h
Normal file
185
Source/DTFluxNetwork/Public/Clients/DTFluxWebSocketClient.h
Normal file
@ -0,0 +1,185 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "IWebSocket.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "Utils/HttpStatusCode.h"
|
||||
#include "Utils/WebSocketStatusCode.h"
|
||||
#include "DTFluxWebSocketClient.generated.h"
|
||||
|
||||
|
||||
USTRUCT()
|
||||
struct FDTFluxWsClientError
|
||||
{
|
||||
GENERATED_BODY()
|
||||
FDTFluxWsClientError()
|
||||
:ClientId(FName("-1")),Reason(FString()), When(FDateTime::Now())
|
||||
{};
|
||||
FDTFluxWsClientError(const FName InName, EDTFluxProtocolError InCode = EDTFluxProtocolError::UnknownError ,
|
||||
FString InReason = FString(""))
|
||||
:ClientId(InName), Code(InCode), Reason(InReason), When(FDateTime::Now()){};
|
||||
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintInternalUseOnly)
|
||||
FName ClientId;
|
||||
|
||||
UPROPERTY()
|
||||
EDTFluxProtocolError Code = EDTFluxProtocolError::NoErrors;
|
||||
|
||||
UPROPERTY()
|
||||
FString Reason;
|
||||
|
||||
UPROPERTY()
|
||||
FDateTime When;
|
||||
|
||||
static FDTFluxWsClientError CreateNoError(FName InClientId)
|
||||
{
|
||||
return FDTFluxWsClientError(InClientId);
|
||||
|
||||
};
|
||||
static FDTFluxWsClientError CreateUnknownError(FName InClientId)
|
||||
{
|
||||
return FDTFluxWsClientError(InClientId, EDTFluxProtocolError::UnknownError);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
class DTFLUXNETWORK_API FDTFluxWebSocketClient : public TSharedFromThis<FDTFluxWebSocketClient>
|
||||
{
|
||||
public:
|
||||
|
||||
FDTFluxWebSocketClient();
|
||||
|
||||
static TSharedPtr<FDTFluxWebSocketClient> GetClient(const TArray<TSharedPtr<FDTFluxWebSocketClient>> InClients, const FName InName)
|
||||
{
|
||||
for(auto Client: InClients)
|
||||
{
|
||||
if(Client->ClientId == InName)
|
||||
{
|
||||
return Client;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Connect();
|
||||
void Reconnect();
|
||||
void Disconnect();
|
||||
FDTFluxWsClientError GetError();
|
||||
void ClearErrors();
|
||||
void AddError(const FDTFluxWsClientError Error);
|
||||
void Send(const FString& Message) const;
|
||||
void SetAddress(FString NewAddress)
|
||||
{
|
||||
WsAddress = NewAddress;
|
||||
}
|
||||
FString GetAddress()
|
||||
{
|
||||
return WsAddress;
|
||||
}
|
||||
|
||||
|
||||
DECLARE_EVENT(FDTFluxWebSocketClient, FWebSocketConnectedEvent);
|
||||
FWebSocketConnectedEvent DTFluxWsClientConnectedEvent;
|
||||
FWebSocketConnectedEvent& RegisterConnectedEvent()
|
||||
{
|
||||
return DTFluxWsClientConnectedEvent;
|
||||
}
|
||||
FWebSocketConnectedEvent& UnregisterConnectedEvent()
|
||||
{
|
||||
return DTFluxWsClientConnectedEvent;
|
||||
}
|
||||
|
||||
DECLARE_EVENT_OneParam(FDTFluxWebSocketClient, FDTFluxWsClientConnectionErrorEvent, const FString& /* Error */);
|
||||
FDTFluxWsClientConnectionErrorEvent DTFluxWsClientConnectionErrorEvent;
|
||||
FDTFluxWsClientConnectionErrorEvent& RegisterConnectionError()
|
||||
{
|
||||
return DTFluxWsClientConnectionErrorEvent;
|
||||
};
|
||||
FDTFluxWsClientConnectionErrorEvent& UnregisterConnectionError()
|
||||
{
|
||||
return DTFluxWsClientConnectionErrorEvent;
|
||||
};
|
||||
|
||||
DECLARE_EVENT_ThreeParams(FDTFluxWebSocketClient, FDTFluxWsClientClosedEvent, int32 /* StatusCode */, const FString& /* Reason */, bool /* bWasClean */);
|
||||
FDTFluxWsClientClosedEvent DTFluxWsClientClosedEvent;
|
||||
FDTFluxWsClientClosedEvent& RegisterClosedEvent()
|
||||
{
|
||||
return DTFluxWsClientClosedEvent;
|
||||
}
|
||||
FDTFluxWsClientClosedEvent& UnregisterClosedEvent()
|
||||
{
|
||||
return DTFluxWsClientClosedEvent;
|
||||
}
|
||||
|
||||
DECLARE_EVENT_OneParam(FDTFluxWebSocketClient, FDTFluxWsClientMessageEvent, const FString& /* MessageString */);
|
||||
FDTFluxWsClientMessageEvent DTFluxWsClientMessageEvent;
|
||||
FDTFluxWsClientMessageEvent& RegisterMessageEvent()
|
||||
{
|
||||
return DTFluxWsClientMessageEvent;
|
||||
};
|
||||
FDTFluxWsClientMessageEvent& UnregisterMessageEvent()
|
||||
{
|
||||
return DTFluxWsClientMessageEvent;
|
||||
};
|
||||
|
||||
DECLARE_EVENT_ThreeParams(FDTFluxWebSocketClient, FDTFluxWsClientBinaryMessageEvent, const void* /* Data */, SIZE_T /* Size */, bool /* bIsLastFragment */);
|
||||
FDTFluxWsClientBinaryMessageEvent DTFluxWsClientBinaryMessageEvent;
|
||||
FDTFluxWsClientBinaryMessageEvent& RegisterBinaryMessageEvent()
|
||||
{
|
||||
return DTFluxWsClientBinaryMessageEvent;
|
||||
};
|
||||
FDTFluxWsClientBinaryMessageEvent& UnregisterBinaryMessageEvent()
|
||||
{
|
||||
return DTFluxWsClientBinaryMessageEvent;
|
||||
};
|
||||
|
||||
DECLARE_EVENT_ThreeParams(FDTFluxWebSocketClient, FDTFluxWsClientRawMessageEvent, const void* /* Data */, SIZE_T /* Size */, SIZE_T /* BytesRemaining */);
|
||||
FDTFluxWsClientRawMessageEvent DTFluxWsClientRawMessageEvent;
|
||||
FDTFluxWsClientRawMessageEvent& RegisterRawMessageEvent()
|
||||
{
|
||||
return DTFluxWsClientRawMessageEvent;
|
||||
};
|
||||
FDTFluxWsClientRawMessageEvent& UnregisterRawMessageEvent()
|
||||
{
|
||||
return DTFluxWsClientRawMessageEvent;
|
||||
};
|
||||
|
||||
DECLARE_EVENT_OneParam(FDTFluxWebSocketClient, FDTFluxWsClientMessageSentEvent, const FString& /* MessageString */);
|
||||
FDTFluxWsClientMessageSentEvent DTFluxWsClientMessageSentEvent;
|
||||
FDTFluxWsClientMessageSentEvent& RegisterMessageSentEvent()
|
||||
{
|
||||
return DTFluxWsClientMessageSentEvent;
|
||||
};
|
||||
FDTFluxWsClientMessageSentEvent& UnregisterMessageSentEvent()
|
||||
{
|
||||
return DTFluxWsClientMessageSentEvent;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void Bind_Internal();
|
||||
void OnConnected_Internal();
|
||||
void OnClientClosed_Internal(int32 StatusCode, const FString& Reason, bool bWasClea);
|
||||
void OnClientError_Internal(const FString& ErrorMessage);
|
||||
void OnClientReceiveMessage_Internal(const FString& Message);
|
||||
void OnClientReceiveBinaryMessage_Internal(const void* Data, SIZE_T Size, bool bIsLastFragment);
|
||||
void OnClientReceiveRawMessage_Internal(const void* Data, SIZE_T Size, SIZE_T BytesRemaining);
|
||||
void OnMessageSent_Internal(const FString& MessageString);
|
||||
void SendMessage_internal(const FString& Message);
|
||||
// void SendBin_internal(void* Data);
|
||||
|
||||
TSharedPtr<IWebSocket> Ws;
|
||||
TArray<FDTFluxWsClientError> Errors;
|
||||
static int32 LastId;
|
||||
FName ClientId;
|
||||
FString WsAddress;
|
||||
static FName DefaultId;
|
||||
};
|
||||
|
||||
|
||||
25
Source/DTFluxNetwork/Public/DTFluxNetworkModule.h
Normal file
25
Source/DTFluxNetwork/Public/DTFluxNetworkModule.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
/**
|
||||
* @module DTFluxNetworkModule
|
||||
* @details DTFlux Project is a framework to integrate all kind of events data from
|
||||
* multiple API (stopwatch servers, etc...) or manually to unreal motion design platform
|
||||
* to create live audiovisual shows.
|
||||
* @brief This module provides all necessary basic class to set up your communication
|
||||
* between an external APIs and unreal engine.
|
||||
* @license See LICENSE.TXT at the of DTFluxAPI plugin folder or at
|
||||
* @see https://github.com/A2MSystemes/DTFluxAPI/blob/main/LICENSE
|
||||
* @author Ange-Marie MAURIN
|
||||
*/
|
||||
|
||||
DTFLUXNETWORK_API DECLARE_LOG_CATEGORY_EXTERN(logDTFluxNetwork, Log, All);
|
||||
|
||||
class FDTFluxNetworkModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
||||
@ -0,0 +1,92 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxCore/Private/Types/DTFluxCoreEnums.h"
|
||||
#include "Subsystems/EngineSubsystem.h"
|
||||
#include "Types/Interfaces/DTFluxDataCollector.h"
|
||||
#include "Types/DTFluxNetworkSettingsTypes.h"
|
||||
#include "DTFluxNetworkSubsystem.generated.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class FDTFluxWebSocketClient;
|
||||
typedef TSharedPtr<FDTFluxWebSocketClient> FDTFluxWebSocketClientSP;
|
||||
class FDTFluxHttpClient;
|
||||
typedef TSharedPtr<FDTFluxHttpClient> FDTFluxHttpClientSP;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class DTFLUXNETWORK_API UFDTFluxNetworkSubsystem : public UEngineSubsystem, public IDTFluxDataCollector
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
EDTFluxConnectionStatus WsStatus = EDTFluxConnectionStatus::Unset;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnWebSocketConnected);
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Network")
|
||||
FOnWebSocketConnected OnWebSocketConnected;
|
||||
|
||||
|
||||
FOnDataReceived DataReceived;
|
||||
virtual FOnDataReceived& OnReceivedData() override
|
||||
{
|
||||
return DataReceived;
|
||||
};
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void Connect();
|
||||
|
||||
protected:
|
||||
// ~Subsystem Interface
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
virtual void Deinitialize() override;
|
||||
// ~Subsystem Interface
|
||||
|
||||
|
||||
private:
|
||||
FDTFluxWsSettings WsSettings;
|
||||
FDTFluxHttpSettings HttpSettings;
|
||||
|
||||
UFUNCTION()
|
||||
void WsSettingsChanged(const FDTFluxWsSettings& NewWsSettings);
|
||||
UFUNCTION()
|
||||
void HttpSettingsChanged(const FDTFluxHttpSettings& NewHttpSettings);
|
||||
void ReconnectWs(const FName WsClientId);
|
||||
void ReconnectHttp(const FName WsClientId);
|
||||
|
||||
void RegisterWebSocketEvents();
|
||||
void RegisterHttpEvents();
|
||||
void UnregisterWebSocketEvents();
|
||||
void UnregisterHttpEvents();
|
||||
|
||||
void OnWebSocketConnected_Subsystem();
|
||||
void OnWebSocketConnectionError_Subsystem(const FString& Error);
|
||||
void OnWebSocketClosedEvent_Subsystem(int32 StatusCode , const FString& Reason, bool bWasClean);
|
||||
void OnWebSocketMessageEvent_Subsystem(const FString& MessageString);
|
||||
void OnWebSocketMessageSentEvent_Subsystem(const FString& MessageSent);
|
||||
|
||||
// TODO : Allow multiple instances of network clients.
|
||||
// // For Future use of Multi-Connections
|
||||
// TArray<FDTFluxWebSocketClientSP> WsClients;
|
||||
// // For Future use of Multi-Connections
|
||||
// TArray<FDTFluxHttpClientSP> HttpClient;
|
||||
// Fo now we jest stick to only one client for each protocol
|
||||
|
||||
FDelegateHandle OnWsConnectedEventDelegateHandle;
|
||||
FDelegateHandle OnWsConnectionErrorEventDelegateHandle;
|
||||
FDelegateHandle OnWsClosedEventDelegateHandle;
|
||||
FDelegateHandle OnWsMessageEventDelegateHandle;
|
||||
FDelegateHandle OnWsMessageSentEventDelegateHandle;
|
||||
|
||||
FDTFluxWebSocketClientSP WsClient = nullptr;
|
||||
FDTFluxHttpClientSP HttpClient = nullptr;
|
||||
|
||||
|
||||
static FString ConstructWsAddress(const FString& Address, const FString& Path, const int& Port);
|
||||
};
|
||||
29
Source/DTFluxNetwork/Public/Utils/DTFluxReceiverChannel.h
Normal file
29
Source/DTFluxNetwork/Public/Utils/DTFluxReceiverChannel.h
Normal file
@ -0,0 +1,29 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Types/Interfaces/DTFluxDataCollector.h"
|
||||
#include "DTFluxReceiverChannel.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct DTFLUXNETWORK_API FDTFluxReceiverChannel
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
FDTFluxReceiverChannel(){};
|
||||
~FDTFluxReceiverChannel(){};
|
||||
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FName ChannelId = FName("FDTFluxReceiverChannel_Default");
|
||||
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
FName ProtocolId = FName("NoProtocol");
|
||||
|
||||
UPROPERTY()
|
||||
TSubclassOf<IDTFluxDataCollector> DataCollectorClass;
|
||||
};
|
||||
131
Source/DTFluxNetwork/Public/Utils/HttpStatusCode.h
Normal file
131
Source/DTFluxNetwork/Public/Utils/HttpStatusCode.h
Normal file
@ -0,0 +1,131 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "HttpStatusCode.generated.h"
|
||||
|
||||
UENUM()
|
||||
enum class EHttpResponseCode: int32
|
||||
{
|
||||
// status code not set yet
|
||||
Unknown = 0 UMETA(DisplayName="Unknown"),
|
||||
|
||||
// the request can be continued.
|
||||
Continue = 100 UMETA(DisplayName="Continue"),
|
||||
|
||||
// the server has switched protocols in an upgrade header.
|
||||
SwitchProtocol = 101 UMETA(DisplayName="Switching Protocols"),
|
||||
|
||||
// the request completed successfully.
|
||||
Ok = 200 UMETA(DisplayName="OK"),
|
||||
|
||||
// the request has been fulfilled and resulted in the creation of a new resource.
|
||||
Created = 201 UMETA(DisplayName="Created"),
|
||||
|
||||
// the request has been accepted for processing, but the processing has not been completed.
|
||||
Accepted = 202 UMETA(DisplayName="Accepted"),
|
||||
|
||||
// the returned meta information in the entity-header is not the definitive set available from the origin server.
|
||||
Partial = 203 UMETA(DisplayName="Non-Authoritative Information"),
|
||||
|
||||
// the server has fulfilled the request, but there is no new information to send back.
|
||||
NoContent = 204 UMETA(DisplayName="No Content"),
|
||||
|
||||
// the request has been completed, and the client program should reset the document view that caused the request to be sent to allow the user to easily initiate another input action.
|
||||
ResetContent = 205 UMETA(DisplayName="Reset Content"),
|
||||
|
||||
// the server has fulfilled the partial get request for the resource.
|
||||
PartialContent = 206 UMETA(DisplayName="Partial Content"),
|
||||
|
||||
// the server couldn't decide what to return.
|
||||
Ambiguous = 300 UMETA(DisplayName="Multiple Choices"),
|
||||
|
||||
// the requested resource has been assigned to a new permanent uri (uniform resource identifier), and any future references to this resource should be done using one of the returned uris.
|
||||
Moved = 301 UMETA(DisplayName="Moved Permanently"),
|
||||
|
||||
// the requested resource resides temporarily under a different uri (uniform resource identifier).
|
||||
Redirect = 302 UMETA(DisplayName="Found"),
|
||||
|
||||
// the response to the request can be found under a different uri (uniform resource identifier) and should be retrieved using a get http verb on that resource.
|
||||
RedirectMethod = 303 UMETA(DisplayName="See Other"),
|
||||
|
||||
// the requested resource has not been modified.
|
||||
NotModified = 304 UMETA(DisplayName="Not Modified"),
|
||||
|
||||
// the requested resource must be accessed through the proxy given by the location field.
|
||||
UseProxy = 305 UMETA(DisplayName="Use Proxy"),
|
||||
|
||||
// the redirected request keeps the same http verb. http/1.1 behavior.
|
||||
RedirectKeepVerb = 307 UMETA(DisplayName="Temporary Redirect"),
|
||||
|
||||
// the request could not be processed by the server due to invalid syntax.
|
||||
BadRequest = 400 UMETA(DisplayName="Bad Request"),
|
||||
|
||||
// the requested resource requires user authentication.
|
||||
Denied = 401 UMETA(DisplayName="Unauthorized"),
|
||||
|
||||
// not currently implemented in the http protocol.
|
||||
PaymentReq = 402 UMETA(DisplayName="Payment Required"),
|
||||
|
||||
// the server understood the request, but is refusing to fulfill it.
|
||||
Forbidden = 403 UMETA(DisplayName="Forbidden"),
|
||||
|
||||
// the server has not found anything matching the requested uri (uniform resource identifier).
|
||||
NotFound = 404 UMETA(DisplayName="Not Found"),
|
||||
|
||||
// the http verb used is not allowed.
|
||||
BadMethod = 405 UMETA(DisplayName="Method Not Allowed"),
|
||||
|
||||
// no responses acceptable to the client were found.
|
||||
NoneAcceptable = 406 UMETA(DisplayName="Not Acceptable"),
|
||||
|
||||
// proxy authentication required.
|
||||
ProxyAuthReq = 407 UMETA(DisplayName="Proxy Authentication Required"),
|
||||
|
||||
// the server timed out waiting for the request.
|
||||
RequestTimeout = 408 UMETA(DisplayName="Request Timeout"),
|
||||
|
||||
// the request could not be completed due to a conflict with the current state of the resource. the user should resubmit with more information.
|
||||
Conflict = 409 UMETA(DisplayName="Conflict"),
|
||||
|
||||
// the requested resource is no longer available at the server, and no forwarding address is known.
|
||||
Gone = 410 UMETA(DisplayName="Gone"),
|
||||
|
||||
// the server refuses to accept the request without a defined content length.
|
||||
LengthRequired = 411 UMETA(DisplayName="Length Required"),
|
||||
|
||||
// the precondition given in one or more of the request header fields evaluated to false when it was tested on the server.
|
||||
PrecondFailed = 412 UMETA(DisplayName="Precondition Failed"),
|
||||
|
||||
// the server is refusing to process a request because the request entity is larger than the server is willing or able to process.
|
||||
RequestTooLarge = 413 UMETA(DisplayName="Payload Too Large"),
|
||||
|
||||
// the server is refusing to service the request because the request uri (uniform resource identifier) is longer than the server is willing to interpret.
|
||||
UriTooLong = 414 UMETA(DisplayName="URI Too Long"),
|
||||
|
||||
// the server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
|
||||
UnsupportedMedia = 415 UMETA(DisplayName="Unsupported Media Type"),
|
||||
|
||||
// too many requests, the server is throttling
|
||||
TooManyRequests = 429 UMETA(DisplayName="Too Many Requests"),
|
||||
|
||||
// the request should be retried after doing the appropriate action.
|
||||
RetryWith = 449 UMETA(DisplayName="Retry With"),
|
||||
|
||||
// the server encountered an unexpected condition that prevented it from fulfilling the request.
|
||||
ServerError = 500 UMETA(DisplayName="Internal Server Error"),
|
||||
|
||||
// the server does not support the functionality required to fulfill the request.
|
||||
NotSupported = 501 UMETA(DisplayName="Not Implemented"),
|
||||
|
||||
// the server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
|
||||
BadGateway = 502 UMETA(DisplayName="Bad Gateway"),
|
||||
|
||||
// the service is temporarily overloaded.
|
||||
ServiceUnavailable = 503 UMETA(DisplayName="Service Unavailable"),
|
||||
|
||||
// the request was timed out waiting for a gateway.
|
||||
GatewayTimeout = 504 UMETA(DisplayName="Gateway Timeout"),
|
||||
|
||||
// the server does not support, or refuses to support, the http protocol version that was used in the request message.
|
||||
VersionNotSup = 505 UMETA(DisplayName="HTTP Version Not Supported")
|
||||
};
|
||||
72
Source/DTFluxNetwork/Public/Utils/WebSocketStatusCode.h
Normal file
72
Source/DTFluxNetwork/Public/Utils/WebSocketStatusCode.h
Normal file
@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
UENUM()
|
||||
enum class EWebSocketCloseCode : int32
|
||||
{
|
||||
// No Error
|
||||
NoError = 0 UMETA(DisplayName="No Errors"),
|
||||
|
||||
// Normal Closure.
|
||||
Normal = 1000 UMETA(DisplayName="Normal Closure"),
|
||||
|
||||
// The endpoint is going away, either because of a server shutdown or because the browser is navigating away from the page that opened the connection.
|
||||
GoingAway = 1001 UMETA(DisplayName="Going Away"),
|
||||
|
||||
// A protocol error occurred.
|
||||
ProtocolError = 1002 UMETA(DisplayName="Protocol Error"),
|
||||
|
||||
// Unsupported data type received.
|
||||
UnsupportedData = 1003 UMETA(DisplayName="Unsupported Data"),
|
||||
|
||||
// Reserved for future use.
|
||||
Reserved = 1004 UMETA(DisplayName="Reserved"),
|
||||
|
||||
// Indicates no status code was provided (must not be sent over the wire).
|
||||
NoStatus = 1005 UMETA(DisplayName="No Status Received"),
|
||||
|
||||
// Connection closed abnormally without receiving a close code.
|
||||
Abnormal = 1006 UMETA(DisplayName="Abnormal Closure"),
|
||||
|
||||
// Invalid frame payload data (e.g., invalid UTF-8 text).
|
||||
InvalidPayload = 1007 UMETA(DisplayName="Invalid Frame Payload Data"),
|
||||
|
||||
// Message violates policy; rejected.
|
||||
PolicyViolation = 1008 UMETA(DisplayName="Policy Violation"),
|
||||
|
||||
// Message too big for processing.
|
||||
MessageTooBig = 1009 UMETA(DisplayName="Message Too Big"),
|
||||
|
||||
// Mandatory extension not supported by server.
|
||||
MandatoryExtension = 1010 UMETA(DisplayName="Mandatory Extension"),
|
||||
|
||||
// Internal server error while processing the connection.
|
||||
InternalServerError = 1011 UMETA(DisplayName="Internal Server Error"),
|
||||
|
||||
// Reserved for future use.
|
||||
ServiceRestart = 1012 UMETA(DisplayName="Service Restart"),
|
||||
|
||||
// Try again later.
|
||||
TryAgainLater = 1013 UMETA(DisplayName="Try Again Later"),
|
||||
|
||||
// TLS handshake failure.
|
||||
TlsHandshake = 1015 UMETA(DisplayName="TLS Handshake")
|
||||
};
|
||||
|
||||
/**
|
||||
* EDTFluxProtocolError
|
||||
* @brief Enum designed for Protocol link errors
|
||||
* @author Ange-Marie MAURIN
|
||||
*/
|
||||
UENUM()
|
||||
enum class EDTFluxProtocolError : uint8
|
||||
{
|
||||
NoErrors = 0,
|
||||
UnknownError = 1,
|
||||
ConnectionError = 2,
|
||||
MaxConnectionsError = 3,
|
||||
TimoutError=4,
|
||||
SerializationError = 5,
|
||||
DeserializationError=6
|
||||
};
|
||||
29
Source/DTFluxProjectSettings/DTFluxProjectSettings.Build.cs
Normal file
29
Source/DTFluxProjectSettings/DTFluxProjectSettings.Build.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class DTFluxProjectSettings : ModuleRules
|
||||
{
|
||||
public DTFluxProjectSettings(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
}
|
||||
);
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
"DeveloperSettings",
|
||||
"DTFluxCore"
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DTFluxGeneralSettings.h"
|
||||
@ -0,0 +1,52 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DTFluxNetworkSettings.h"
|
||||
#include "Types/DTFluxNetworkSettingsTypes.h"
|
||||
|
||||
UDTFluxNetworkSettings::UDTFluxNetworkSettings()
|
||||
{
|
||||
CategoryName = "DTFlux API";
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
void UDTFluxNetworkSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||
{
|
||||
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||
FString PropertyId = PropertyChangedEvent.GetPropertyName().ToString();
|
||||
if(PropertyId.Contains("WebSocket"))
|
||||
{
|
||||
FDTFluxWsSettings WsSettings;
|
||||
GetWebSocketSettings(this, WsSettings);
|
||||
OnDTFluxWebSocketSettingsChanged.Broadcast(WsSettings);
|
||||
}
|
||||
if(PropertyId.Contains("HTTP"))
|
||||
{
|
||||
FDTFluxHttpSettings HTTPSettings;
|
||||
GetHTTPSettings(this, HTTPSettings);
|
||||
OnDTFluxHttpSettingsChanged.Broadcast(HTTPSettings);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void UDTFluxNetworkSettings::GetHTTPSettings(const UDTFluxNetworkSettings* Settings,
|
||||
FDTFluxHttpSettings& OutHTTPSettings)
|
||||
{
|
||||
OutHTTPSettings.Address = Settings->HTTPAddress;
|
||||
OutHTTPSettings.Port = Settings->HTTPPort;
|
||||
OutHTTPSettings.Path = Settings->HTTPPath;
|
||||
}
|
||||
|
||||
void UDTFluxNetworkSettings::GetWebSocketSettings(const UDTFluxNetworkSettings* Settings,
|
||||
FDTFluxWsSettings& OutWsSettings)
|
||||
{
|
||||
OutWsSettings.Address = Settings->WebSocketAddress;
|
||||
OutWsSettings.Path = Settings->WebSocketPath;
|
||||
OutWsSettings.Port = Settings->WebSocketPort;
|
||||
OutWsSettings.bShouldAutoReconnectOnClosed = Settings->bWebSocketShouldReconnectOnClosed;
|
||||
OutWsSettings.bShouldConnectAtStartup = Settings->bWebSocketShouldConnectAtStartup;
|
||||
OutWsSettings.bShouldAutoReconnectOnError = Settings->bWebSocketShouldReconnectOnError;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
#include "DTFluxProjectSettingsModule.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDTFluxProjectSettingsModule"
|
||||
|
||||
DTFLUXPROJECTSETTINGS_API DEFINE_LOG_CATEGORY(logDTFluxProjectSettings)
|
||||
|
||||
void FDTFluxProjectSettingsModule::StartupModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FDTFluxProjectSettingsModule::ShutdownModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDTFluxProjectSettingsModule, DTFluxProjectSettings)
|
||||
18
Source/DTFluxProjectSettings/Public/DTFluxGeneralSettings.h
Normal file
18
Source/DTFluxProjectSettings/Public/DTFluxGeneralSettings.h
Normal file
@ -0,0 +1,18 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DeveloperSettings.h"
|
||||
#include "DTFluxGeneralSettings.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DTFLUXPROJECTSETTINGS_API UDTFluxGeneralSettings : public UDeveloperSettings
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
};
|
||||
65
Source/DTFluxProjectSettings/Public/DTFluxNetworkSettings.h
Normal file
65
Source/DTFluxProjectSettings/Public/DTFluxNetworkSettings.h
Normal file
@ -0,0 +1,65 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "DTFluxNetworkSettings.generated.h"
|
||||
|
||||
struct FDTFluxHttpSettings;
|
||||
struct FDTFluxWsSettings;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Config=Engine, DefaultConfig, meta=(DisplayName="DTFlux Project Settings"))
|
||||
class DTFLUXPROJECTSETTINGS_API UDTFluxNetworkSettings : public UDeveloperSettings
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UDTFluxNetworkSettings();
|
||||
|
||||
UPROPERTY(Category="CHRONO PROXY|Websocket", Config, EditAnywhere, BlueprintReadOnly, DisplayName="Websocket Port")
|
||||
int WebSocketPort = 3000;
|
||||
|
||||
UPROPERTY(Category="CHRONO PROXY|Websocket", Config, EditAnywhere, BlueprintReadOnly, DisplayName="Websocket Address")
|
||||
FString WebSocketAddress = "127.0.0.1";
|
||||
|
||||
UPROPERTY(Category="CHRONO PROXY|Websocket", Config, EditAnywhere, BlueprintReadOnly, DisplayName="Websocket Path")
|
||||
FString WebSocketPath = "/api/v1";
|
||||
|
||||
UPROPERTY(Category="CHRONO PROXY|Websocket", Config, EditAnywhere, BlueprintReadOnly, DisplayName="Autoconnect to WebSocket Server at startup")
|
||||
bool bWebSocketShouldConnectAtStartup = false;
|
||||
|
||||
UPROPERTY(Category="CHRONO PROXY|Websocket", Config, EditAnywhere, BlueprintReadOnly, DisplayName="Auto Reconnect On WebSocket Closed")
|
||||
bool bWebSocketShouldReconnectOnClosed = false;
|
||||
|
||||
UPROPERTY(Category="CHRONO PROXY|Websocket", Config, EditAnywhere, BlueprintReadOnly, DisplayName="Auto Reconnect On WebSocket Error")
|
||||
bool bWebSocketShouldReconnectOnError = false;
|
||||
|
||||
UPROPERTY(Category="CHRONO PROXY|HTTP", Config, EditAnywhere, BlueprintReadOnly, DisplayName="HTTP Address")
|
||||
FString HTTPAddress = "http://localhost";
|
||||
|
||||
UPROPERTY(Category="CHRONO PROXY|HTTP", Config, EditAnywhere, BlueprintReadOnly, DisplayName="HTTP Path")
|
||||
FString HTTPPath = "/";
|
||||
|
||||
UPROPERTY(Category="CHRONO PROXY|HTTP", Config, EditAnywhere, BlueprintReadOnly, DisplayName="HTTP Port")
|
||||
int HTTPPort = 8080;
|
||||
|
||||
|
||||
|
||||
#if WITH_EDITOR
|
||||
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||
|
||||
DECLARE_MULTICAST_DELEGATE_OneParam(FOnDTFluxHttpSettingsChanged, const FDTFluxHttpSettings&);
|
||||
DECLARE_MULTICAST_DELEGATE_OneParam(FOnDTFluxWebSocketSettingsChanged, const FDTFluxWsSettings&);
|
||||
FOnDTFluxHttpSettingsChanged OnDTFluxHttpSettingsChanged;
|
||||
FOnDTFluxWebSocketSettingsChanged OnDTFluxWebSocketSettingsChanged;
|
||||
|
||||
#endif
|
||||
static void GetHTTPSettings(const UDTFluxNetworkSettings* Settings, FDTFluxHttpSettings& OutHTTPSettings);
|
||||
static void GetWebSocketSettings(const UDTFluxNetworkSettings* Settings, FDTFluxWsSettings& OutWsSettings);
|
||||
|
||||
};
|
||||
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
/**
|
||||
* @module DTFluxProjectSettings
|
||||
* @details DTFlux Project is a framework to integrate all kind of events data from
|
||||
* multiple API (stopwatch servers, etc...) or manually to unreal motion design platform
|
||||
* to create live audiovisual shows.
|
||||
* @brief This module provides all defines the projects settings for this plugin
|
||||
* @license See LICENSE.TXT at the of DTFluxAPI plugin folder or at
|
||||
* @see https://github.com/A2MSystemes/DTFluxAPI/blob/main/LICENSE
|
||||
* @author Ange-Marie MAURIN
|
||||
*/
|
||||
DTFLUXPROJECTSETTINGS_API DECLARE_LOG_CATEGORY_EXTERN(logDTFluxProjectSettings, Log, All)
|
||||
|
||||
class FDTFluxProjectSettingsModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
||||
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxNetworkSettingsTypes.generated.h"
|
||||
|
||||
|
||||
USTRUCT()
|
||||
struct FDTFluxWsSettings
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
FDTFluxWsSettings():
|
||||
Path(TEXT("")),
|
||||
Address(TEXT(""))
|
||||
{}
|
||||
|
||||
UPROPERTY()
|
||||
int Port = -1;
|
||||
UPROPERTY()
|
||||
FString Path;
|
||||
UPROPERTY()
|
||||
FString Address;
|
||||
UPROPERTY()
|
||||
bool bShouldAutoReconnectOnClosed = false;
|
||||
UPROPERTY()
|
||||
bool bShouldConnectAtStartup = false;
|
||||
UPROPERTY()
|
||||
bool bShouldAutoReconnectOnError = false;
|
||||
|
||||
bool operator==(const FDTFluxWsSettings& Right) const
|
||||
{
|
||||
return Port == Right.Port || Path == Right.Path || Address == Right.Address;
|
||||
};
|
||||
bool operator!=(const FDTFluxWsSettings& Right) const
|
||||
{
|
||||
return Port != Right.Port || Path != Right.Path || Address != Right.Address;
|
||||
}
|
||||
};
|
||||
|
||||
USTRUCT()
|
||||
struct FDTFluxHttpSettings
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
FDTFluxHttpSettings():
|
||||
Port(-1),
|
||||
Path(TEXT("")),
|
||||
Address(TEXT("")){}
|
||||
|
||||
UPROPERTY()
|
||||
int Port;
|
||||
UPROPERTY()
|
||||
FString Path;
|
||||
UPROPERTY()
|
||||
FString Address;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user