diff --git a/Content/ThirdPersonBP/Blueprints/ThirdPersonCharacter.uasset b/Content/ThirdPersonBP/Blueprints/ThirdPersonCharacter.uasset index 0ae5b1b..24ba6d9 100644 Binary files a/Content/ThirdPersonBP/Blueprints/ThirdPersonCharacter.uasset and b/Content/ThirdPersonBP/Blueprints/ThirdPersonCharacter.uasset differ diff --git a/Plugins/HypeRateHeartbeat/Config/FilterPlugin.ini b/Plugins/HypeRateHeartbeat/Config/FilterPlugin.ini new file mode 100644 index 0000000..ccebca2 --- /dev/null +++ b/Plugins/HypeRateHeartbeat/Config/FilterPlugin.ini @@ -0,0 +1,8 @@ +[FilterPlugin] +; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and +; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively. +; +; Examples: +; /README.txt +; /Extras/... +; /Binaries/ThirdParty/*.dll diff --git a/Plugins/HypeRateHeartbeat/HypeRateHeartbeat.uplugin b/Plugins/HypeRateHeartbeat/HypeRateHeartbeat.uplugin index 3a2d434..938ab0d 100644 --- a/Plugins/HypeRateHeartbeat/HypeRateHeartbeat.uplugin +++ b/Plugins/HypeRateHeartbeat/HypeRateHeartbeat.uplugin @@ -2,14 +2,14 @@ "FileVersion": 3, "Version": 1, "VersionName": "1.0", - "FriendlyName": "HypeRateHeartbeat", - "Description": "HypeRate Heartbeat Plugin", - "Category": "Other", + "FriendlyName": "HypeRate.io Heartbeat receiver", + "Description": "HypeRate.io Unreal Engine Plugin", + "Category": "Hype Rate", "CreatedBy": "Max 'ReDiGermany' Kruggel", "CreatedByURL": "https://github.com/ReDiGermany", - "DocsURL": "", + "DocsURL": "https://github.com/ReDiGermany/HypeRateUE", "MarketplaceURL": "", - "SupportURL": "", + "SupportURL": "https://github.com/ReDiGermany/HypeRateUE/issues", "CanContainContent": true, "IsBetaVersion": false, "IsExperimentalVersion": false, diff --git a/Plugins/HypeRateHeartbeat/Resources/Icon128.png b/Plugins/HypeRateHeartbeat/Resources/Icon128.png index 1231d4a..c978be9 100644 Binary files a/Plugins/HypeRateHeartbeat/Resources/Icon128.png and b/Plugins/HypeRateHeartbeat/Resources/Icon128.png differ diff --git a/Plugins/HypeRateHeartbeat/Source/HypeRateHeartbeat/Private/BPHypeRateHeartbeat.cpp b/Plugins/HypeRateHeartbeat/Source/HypeRateHeartbeat/Private/BPHypeRateHeartbeat.cpp index 888bcdd..f6bf0fb 100644 --- a/Plugins/HypeRateHeartbeat/Source/HypeRateHeartbeat/Private/BPHypeRateHeartbeat.cpp +++ b/Plugins/HypeRateHeartbeat/Source/HypeRateHeartbeat/Private/BPHypeRateHeartbeat.cpp @@ -5,6 +5,19 @@ bool UBPHypeRateHeartbeat::isConnected = false; int UBPHypeRateHeartbeat::lastHeartBeat = 80; TSharedPtr UBPHypeRateHeartbeat::Socket = nullptr; +std::thread UBPHypeRateHeartbeat::thr = std::thread([]{ + + while (true) { + if (UBPHypeRateHeartbeat::isConnected) { + UE_LOG(LogTemp, Log, TEXT("[HYPERATE::DEV] Ping?")); + if (UBPHypeRateHeartbeat::Socket->IsConnected()) { + UBPHypeRateHeartbeat::Socket->Send("{\"topic\": \"phoenix\",\"event\": \"heartbeat\",\"payload\": {},\"ref\": 0}"); + UE_LOG(LogTemp, Log, TEXT("[HYPERATE::DEV] Ping")); + } + } + std::this_thread::sleep_for(std::chrono::milliseconds(20 * 1000)); + } + }); void UBPHypeRateHeartbeat::Connect(FString Topic, FString WebsocketKey) @@ -17,8 +30,7 @@ void UBPHypeRateHeartbeat::Connect(FString Topic, FString WebsocketKey) const FString ServerProtocol = TEXT("wss"); // The WebServer protocol you want to use. Socket = FWebSocketsModule::Get().CreateWebSocket(ServerURL, ServerProtocol); - // We bind all available events - Socket->OnConnected().AddLambda([&, Topic]() -> void { + Socket->OnConnected().AddLambda([ Topic]() -> void { UE_LOG(LogTemp, Log, TEXT("[HYPERATE::DEV] OnConnected")); FString s = FString("{\"topic\": \"hr:" + Topic + "\", \"event\": \"phx_join\",\"payload\": {},\"ref\": 0}"); @@ -29,7 +41,7 @@ void UBPHypeRateHeartbeat::Connect(FString Topic, FString WebsocketKey) UE_LOG(LogTemp, Log, TEXT("[HYPERATE::DEV] Connection to websocket server has been closed with status code: \"%d\" and reason: \"%s\"."), StatusCode, *Reason); }); - Socket->OnMessage().AddLambda([&](const FString& Message) -> void { + Socket->OnMessage().AddLambda([](const FString& Message) -> void { UE_LOG(LogTemp, Log, TEXT("[HYPERATE::DEV] OnMessage %s"), *Message); TSharedPtr JsonParsed; TSharedRef> JsonReader = TJsonReaderFactory::Create(*Message); @@ -41,7 +53,6 @@ void UBPHypeRateHeartbeat::Connect(FString Topic, FString WebsocketKey) UE_LOG(LogTemp, Log, TEXT("[HYPERATE::DEV] OnMessage hr %s"), *FString::FromInt(hr)); lastHeartBeat = hr; - //HeartBeatUpdate(hr); } }); @@ -52,13 +63,6 @@ void UBPHypeRateHeartbeat::Connect(FString Topic, FString WebsocketKey) Socket->OnConnectionError().AddLambda([](const FString& Error) -> void { UE_LOG(LogTemp, Log, TEXT("[HYPERATE::DEV] OnConnectionError %s"), *Error); }); - std::thread([&]() { - while (Socket->IsConnected()) { - Socket->Send("{\"topic\": \"phoenix\",\"event\": \"heartbeat\",\"payload\": {},\"ref\": 0}"); - std::this_thread::sleep_for(std::chrono::milliseconds(20 * 1000)); - UE_LOG(LogTemp, Log, TEXT("[HYPERATE::DEV] Ping")); - } - }).detach(); Socket->Connect(); } @@ -73,6 +77,7 @@ void UBPHypeRateHeartbeat::Disconnect() { if (!Socket->IsConnected()) return; isConnected = false; Socket->Close(); + //thr.join(); UE_LOG(LogTemp, Log, TEXT("[HYPERATE::DEV] Closed")); } diff --git a/Plugins/HypeRateHeartbeat/Source/HypeRateHeartbeat/Public/BPHypeRateHeartbeat.h b/Plugins/HypeRateHeartbeat/Source/HypeRateHeartbeat/Public/BPHypeRateHeartbeat.h index 907a2b1..988f8da 100644 --- a/Plugins/HypeRateHeartbeat/Source/HypeRateHeartbeat/Public/BPHypeRateHeartbeat.h +++ b/Plugins/HypeRateHeartbeat/Source/HypeRateHeartbeat/Public/BPHypeRateHeartbeat.h @@ -32,4 +32,6 @@ class HYPERATEHEARTBEAT_API UBPHypeRateHeartbeat : public UBlueprintFunctionLibr static bool isConnected; static TSharedPtr Socket; + + static std::thread thr; };