diff --git a/RSHWNetwork.uplugin b/RSHWNetwork.uplugin deleted file mode 100644 index 0e1d314..0000000 --- a/RSHWNetwork.uplugin +++ /dev/null @@ -1,29 +0,0 @@ -{ - "FileVersion": 3, - "Version": 1, - "VersionName": "1.0", - "FriendlyName": "[RSHW] Network", - "Description": "", - "Category": "RSHW", - "CreatedBy": "_Redstone_c_", - "CreatedByURL": "", - "DocsURL": "", - "MarketplaceURL": "", - "SupportURL": "", - "CanContainContent": true, - "IsBetaVersion": false, - "IsExperimentalVersion": false, - "Installed": false, - "Modules": [ - { - "Name": "RSHWNetwork", - "Type": "Runtime", - "LoadingPhase": "Default" - }, - { - "Name": "KCP", - "Type": "Runtime", - "LoadingPhase": "Default" - } - ] -} \ No newline at end of file diff --git a/RedNetwork.uplugin b/RedNetwork.uplugin new file mode 100644 index 0000000..d35719f --- /dev/null +++ b/RedNetwork.uplugin @@ -0,0 +1,29 @@ +{ + "FileVersion": 3, + "Version": 1, + "VersionName": "1.0", + "FriendlyName": "Red Network", + "Description": "", + "Category": "Networking", + "CreatedBy": "_Redstone_c_", + "CreatedByURL": "", + "DocsURL": "", + "MarketplaceURL": "", + "SupportURL": "", + "CanContainContent": false, + "IsBetaVersion": false, + "IsExperimentalVersion": false, + "Installed": false, + "Modules": [ + { + "Name": "RedNetwork", + "Type": "Runtime", + "LoadingPhase": "Default" + }, + { + "Name": "KCP", + "Type": "Runtime", + "LoadingPhase": "Default" + } + ] +} \ No newline at end of file diff --git a/Source/RSHWNetwork/Private/Logging.cpp b/Source/RSHWNetwork/Private/Logging.cpp deleted file mode 100644 index ef9cbd2..0000000 --- a/Source/RSHWNetwork/Private/Logging.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "Logging.h" - -DEFINE_LOG_CATEGORY(LogRSHWNetwork); diff --git a/Source/RSHWNetwork/Private/RSHWNetworkType.cpp b/Source/RSHWNetwork/Private/RSHWNetworkType.cpp deleted file mode 100644 index 7bb4703..0000000 --- a/Source/RSHWNetwork/Private/RSHWNetworkType.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "RSHWNetworkType.h" diff --git a/Source/RedNetwork/Private/Logging.cpp b/Source/RedNetwork/Private/Logging.cpp new file mode 100644 index 0000000..9a14d2a --- /dev/null +++ b/Source/RedNetwork/Private/Logging.cpp @@ -0,0 +1,3 @@ +#include "Logging.h" + +DEFINE_LOG_CATEGORY(LogRedNetwork); diff --git a/Source/RSHWNetwork/Private/Logging.h b/Source/RedNetwork/Private/Logging.h similarity index 57% rename from Source/RSHWNetwork/Private/Logging.h rename to Source/RedNetwork/Private/Logging.h index 19c7c25..c23c2cc 100644 --- a/Source/RSHWNetwork/Private/Logging.h +++ b/Source/RedNetwork/Private/Logging.h @@ -3,4 +3,4 @@ #include "CoreMinimal.h" #include "Modules/ModuleManager.h" -DECLARE_LOG_CATEGORY_EXTERN(LogRSHWNetwork, Log, All); +DECLARE_LOG_CATEGORY_EXTERN(LogRedNetwork, Log, All); diff --git a/Source/RSHWNetwork/Private/RSHWNetwork.cpp b/Source/RedNetwork/Private/RedNetwork.cpp similarity index 65% rename from Source/RSHWNetwork/Private/RSHWNetwork.cpp rename to Source/RedNetwork/Private/RedNetwork.cpp index bd66a64..919b156 100644 --- a/Source/RSHWNetwork/Private/RSHWNetwork.cpp +++ b/Source/RedNetwork/Private/RedNetwork.cpp @@ -1,15 +1,15 @@ // Copyright Epic Games, Inc. All Rights Reserved. -#include "RSHWNetwork.h" +#include "RedNetwork.h" -#define LOCTEXT_NAMESPACE "FRSHWNetworkModule" +#define LOCTEXT_NAMESPACE "FRedNetworkModule" -void FRSHWNetworkModule::StartupModule() +void FRedNetworkModule::StartupModule() { // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module } -void FRSHWNetworkModule::ShutdownModule() +void FRedNetworkModule::ShutdownModule() { // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, // we call this function before unloading the module. @@ -17,4 +17,4 @@ void FRSHWNetworkModule::ShutdownModule() #undef LOCTEXT_NAMESPACE -IMPLEMENT_MODULE(FRSHWNetworkModule, RSHWNetwork) \ No newline at end of file +IMPLEMENT_MODULE(FRedNetworkModule, RedNetwork) \ No newline at end of file diff --git a/Source/RSHWNetwork/Private/RSHWNetworkClient.cpp b/Source/RedNetwork/Private/RedNetworkClient.cpp similarity index 84% rename from Source/RSHWNetwork/Private/RSHWNetworkClient.cpp rename to Source/RedNetwork/Private/RedNetworkClient.cpp index 3c96164..a2bd877 100644 --- a/Source/RSHWNetwork/Private/RSHWNetworkClient.cpp +++ b/Source/RedNetwork/Private/RedNetworkClient.cpp @@ -1,4 +1,4 @@ -#include "RSHWNetworkClient.h" +#include "RedNetworkClient.h" #include "KCPWrap.h" #include "Logging.h" @@ -6,14 +6,14 @@ #include "IPAddress.h" #include "SocketSubsystem.h" -bool URSHWNetworkClient::Send(const TArray& Data) +bool URedNetworkClient::Send(const TArray& Data) { if (!IsActive() || !(ClientPass.ID | ClientPass.Key)) return false; return KCPUnit->Send(Data.GetData(), Data.Num()); } -int32 URSHWNetworkClient::UDPSend(const uint8 * Data, int32 Count) +int32 URedNetworkClient::UDPSend(const uint8 * Data, int32 Count) { if (!IsActive() || !(ClientPass.ID | ClientPass.Key)) return false; @@ -36,7 +36,7 @@ int32 URSHWNetworkClient::UDPSend(const uint8 * Data, int32 Count) return 0; } -void URSHWNetworkClient::Tick(float DeltaTime) +void URedNetworkClient::Tick(float DeltaTime) { if (!IsActive()) return; @@ -91,7 +91,7 @@ void URSHWNetworkClient::Tick(float DeltaTime) if (BytesRead < 8) continue; RecvBuffer.SetNumUninitialized(BytesRead, false); - FRSHWNetworkPass SourcePass; + FRedNetworkPass SourcePass; SourcePass.ID = 0; SourcePass.Key = 0; @@ -167,14 +167,14 @@ void URSHWNetworkClient::Tick(float DeltaTime) KCPUnit = nullptr; - UE_LOG(LogRSHWNetwork, Warning, TEXT("RSHW Network Client timeout.")); + UE_LOG(LogRedNetwork, Warning, TEXT("Red Network Client timeout.")); OnUnlogin.Broadcast(); } } } -void URSHWNetworkClient::Activate(bool bReset) +void URedNetworkClient::Activate(bool bReset) { if (bReset) Deactivate(); if (bIsActive) return; @@ -183,7 +183,7 @@ void URSHWNetworkClient::Activate(bool bReset) if (SocketSubsystem == nullptr) { - UE_LOG(LogRSHWNetwork, Error, TEXT("Socket subsystem is nullptr.")); + UE_LOG(LogRedNetwork, Error, TEXT("Socket subsystem is nullptr.")); return; } @@ -195,22 +195,22 @@ void URSHWNetworkClient::Activate(bool bReset) if (!bIsValid) { - UE_LOG(LogRSHWNetwork, Error, TEXT("Server addr invalid.")); + UE_LOG(LogRedNetwork, Error, TEXT("Server addr invalid.")); ServerAddrPtr = nullptr; return; } - SocketPtr = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("RSHW Client Socket")); + SocketPtr = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("Red Client Socket")); if (SocketPtr == nullptr) { - UE_LOG(LogRSHWNetwork, Error, TEXT("Socket creation failed.")); + UE_LOG(LogRedNetwork, Error, TEXT("Socket creation failed.")); return; } if (!SocketPtr->SetNonBlocking()) { - UE_LOG(LogRSHWNetwork, Error, TEXT("Socket set non-blocking failed.")); + UE_LOG(LogRedNetwork, Error, TEXT("Socket set non-blocking failed.")); SocketSubsystem->DestroySocket(SocketPtr); return; } @@ -219,12 +219,12 @@ void URSHWNetworkClient::Activate(bool bReset) ClientPass.Key = 0; LastRecvTime = FDateTime::Now(); LastHeartbeat = FDateTime::MinValue(); - UE_LOG(LogRSHWNetwork, Log, TEXT("RSHW Network Client activate.")); + UE_LOG(LogRedNetwork, Log, TEXT("Red Network Client activate.")); bIsActive = true; } -void URSHWNetworkClient::Deactivate() +void URedNetworkClient::Deactivate() { if (!bIsActive) return; @@ -246,12 +246,12 @@ void URSHWNetworkClient::Deactivate() KCPUnit = nullptr; - UE_LOG(LogRSHWNetwork, Log, TEXT("RSHW Network Client deactivate.")); + UE_LOG(LogRedNetwork, Log, TEXT("Red Network Client deactivate.")); bIsActive = false; } -void URSHWNetworkClient::BeginDestroy() +void URedNetworkClient::BeginDestroy() { Deactivate(); diff --git a/Source/RSHWNetwork/Private/RSHWNetworkServer.cpp b/Source/RedNetwork/Private/RedNetworkServer.cpp similarity index 84% rename from Source/RSHWNetwork/Private/RSHWNetworkServer.cpp rename to Source/RedNetwork/Private/RedNetworkServer.cpp index 684374c..bc973e9 100644 --- a/Source/RSHWNetwork/Private/RSHWNetworkServer.cpp +++ b/Source/RedNetwork/Private/RedNetworkServer.cpp @@ -1,4 +1,4 @@ -#include "RSHWNetworkServer.h" +#include "RedNetworkServer.h" #include "KCPWrap.h" #include "Logging.h" @@ -7,7 +7,7 @@ #include "SocketSubsystem.h" #include "HAL/UnrealMemory.h" -bool URSHWNetworkServer::Send(int32 ClientID, const TArray& Data) +bool URedNetworkServer::Send(int32 ClientID, const TArray& Data) { if (!IsActive() || !Registration.Contains(ClientID)) return false; @@ -16,7 +16,7 @@ bool URSHWNetworkServer::Send(int32 ClientID, const TArray& Data) return !Info.KCPUnit->Send(Data.GetData(), Data.Num()); } -int32 URSHWNetworkServer::UDPSend(int32 ClientID, const uint8* Data, int32 Count) +int32 URedNetworkServer::UDPSend(int32 ClientID, const uint8* Data, int32 Count) { if (!IsActive() || !Registration.Contains(ClientID)) return false; @@ -41,7 +41,7 @@ int32 URSHWNetworkServer::UDPSend(int32 ClientID, const uint8* Data, int32 Count return 0; } -void URSHWNetworkServer::Tick(float DeltaTime) +void URedNetworkServer::Tick(float DeltaTime) { if (!IsActive()) return; @@ -107,7 +107,7 @@ void URSHWNetworkServer::Tick(float DeltaTime) if (BytesRead < 8) continue; RecvBuffer.SetNumUninitialized(BytesRead, false); - FRSHWNetworkPass SourcePass; + FRedNetworkPass SourcePass; SourcePass.ID = 0; SourcePass.Key = 0; @@ -138,10 +138,10 @@ void URSHWNetworkServer::Tick(float DeltaTime) PreRegistration.Add(SourceAddrStr, NewRegistration); - UE_LOG(LogRSHWNetwork, Log, TEXT("Pre-register pass %i from %s."), NewRegistration.Pass.ID, *SourceAddrStr); + UE_LOG(LogRedNetwork, Log, TEXT("Pre-register pass %i from %s."), NewRegistration.Pass.ID, *SourceAddrStr); } - const FRSHWNetworkPass& Pass = PreRegistration[SourceAddrStr].Pass; + const FRedNetworkPass& Pass = PreRegistration[SourceAddrStr].Pass; SendBuffer.SetNum(8, false); @@ -158,7 +158,7 @@ void URSHWNetworkServer::Tick(float DeltaTime) int32 BytesSend; if (SocketPtr->SendTo(SendBuffer.GetData(), SendBuffer.Num(), BytesSend, *SourceAddr) && BytesSend == SendBuffer.Num()) { - UE_LOG(LogRSHWNetwork, Log, TEXT("Send pre-registration pass %i to %s."), Pass.ID, *SourceAddrStr); + UE_LOG(LogRedNetwork, Log, TEXT("Send pre-registration pass %i to %s."), Pass.ID, *SourceAddrStr); } } else @@ -170,7 +170,7 @@ void URSHWNetworkServer::Tick(float DeltaTime) { Registration[SourcePass.ID].Addr = SourceAddr; - UE_LOG(LogRSHWNetwork, Log, TEXT("Redirect connection %i."), SourcePass.ID); + UE_LOG(LogRedNetwork, Log, TEXT("Redirect connection %i."), SourcePass.ID); } } @@ -207,7 +207,7 @@ void URSHWNetworkServer::Tick(float DeltaTime) PreRegistration.Remove(SourceAddrStr); - UE_LOG(LogRSHWNetwork, Log, TEXT("Register connection %i."), SourcePass.ID); + UE_LOG(LogRedNetwork, Log, TEXT("Register connection %i."), SourcePass.ID); OnLogin.Broadcast(SourcePass.ID); } @@ -239,7 +239,7 @@ void URSHWNetworkServer::Tick(float DeltaTime) { if (NowTime - PreRegistration[Addr].Time > TimeoutLimit) { - UE_LOG(LogRSHWNetwork, Log, TEXT("Pre-registration pass %i timeout."), PreRegistration[Addr].Pass.ID); + UE_LOG(LogRedNetwork, Log, TEXT("Pre-registration pass %i timeout."), PreRegistration[Addr].Pass.ID); PreRegistration.Remove(Addr); } @@ -255,7 +255,7 @@ void URSHWNetworkServer::Tick(float DeltaTime) { if (NowTime - Registration[ID].RecvTime > TimeoutLimit) { - UE_LOG(LogRSHWNetwork, Log, TEXT("Registration connection %i timeout."), Registration[ID].Pass.ID); + UE_LOG(LogRedNetwork, Log, TEXT("Registration connection %i timeout."), Registration[ID].Pass.ID); Registration.Remove(ID); @@ -291,7 +291,7 @@ void URSHWNetworkServer::Tick(float DeltaTime) } } -void URSHWNetworkServer::Activate(bool bReset) +void URedNetworkServer::Activate(bool bReset) { if (bReset) Deactivate(); if (bIsActive) return; @@ -300,15 +300,15 @@ void URSHWNetworkServer::Activate(bool bReset) if (SocketSubsystem == nullptr) { - UE_LOG(LogRSHWNetwork, Error, TEXT("Socket subsystem is nullptr.")); + UE_LOG(LogRedNetwork, Error, TEXT("Socket subsystem is nullptr.")); return; } - SocketPtr = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("RSHW Server Socket")); + SocketPtr = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("Red Server Socket")); if (SocketPtr == nullptr) { - UE_LOG(LogRSHWNetwork, Error, TEXT("Socket creation failed.")); + UE_LOG(LogRedNetwork, Error, TEXT("Socket creation failed.")); return; } @@ -319,26 +319,26 @@ void URSHWNetworkServer::Activate(bool bReset) if (!SocketPtr->Bind(*ServerAddr)) { - UE_LOG(LogRSHWNetwork, Error, TEXT("Socket bind failed.")); + UE_LOG(LogRedNetwork, Error, TEXT("Socket bind failed.")); SocketSubsystem->DestroySocket(SocketPtr); return; } if (!SocketPtr->SetNonBlocking()) { - UE_LOG(LogRSHWNetwork, Error, TEXT("Socket set non-blocking failed.")); + UE_LOG(LogRedNetwork, Error, TEXT("Socket set non-blocking failed.")); SocketSubsystem->DestroySocket(SocketPtr); return; } NextRegistrationID = 1; - UE_LOG(LogRSHWNetwork, Log, TEXT("RSHW Network Server activate.")); + UE_LOG(LogRedNetwork, Log, TEXT("Red Network Server activate.")); bIsActive = true; } -void URSHWNetworkServer::Deactivate() +void URedNetworkServer::Deactivate() { if (!bIsActive) return; @@ -361,12 +361,12 @@ void URSHWNetworkServer::Deactivate() PreRegistration.Reset(); Registration.Reset(); - UE_LOG(LogRSHWNetwork, Log, TEXT("RSHW Network Server deactivate.")); + UE_LOG(LogRedNetwork, Log, TEXT("Red Network Server deactivate.")); bIsActive = false; } -void URSHWNetworkServer::BeginDestroy() +void URedNetworkServer::BeginDestroy() { Deactivate(); diff --git a/Source/RedNetwork/Private/RedNetworkType.cpp b/Source/RedNetwork/Private/RedNetworkType.cpp new file mode 100644 index 0000000..18bc0a8 --- /dev/null +++ b/Source/RedNetwork/Private/RedNetworkType.cpp @@ -0,0 +1 @@ +#include "RedNetworkType.h" diff --git a/Source/RSHWNetwork/Public/RSHWNetwork.h b/Source/RedNetwork/Public/RedNetwork.h similarity index 83% rename from Source/RSHWNetwork/Public/RSHWNetwork.h rename to Source/RedNetwork/Public/RedNetwork.h index a6aa878..a72b843 100644 --- a/Source/RSHWNetwork/Public/RSHWNetwork.h +++ b/Source/RedNetwork/Public/RedNetwork.h @@ -5,7 +5,7 @@ #include "CoreMinimal.h" #include "Modules/ModuleManager.h" -class FRSHWNetworkModule : public IModuleInterface +class FRedNetworkModule : public IModuleInterface { public: diff --git a/Source/RSHWNetwork/Public/RSHWNetworkClient.h b/Source/RedNetwork/Public/RedNetworkClient.h similarity index 57% rename from Source/RSHWNetwork/Public/RSHWNetworkClient.h rename to Source/RedNetwork/Public/RedNetworkClient.h index 09608ec..c3edf79 100644 --- a/Source/RSHWNetwork/Public/RSHWNetworkClient.h +++ b/Source/RedNetwork/Public/RedNetworkClient.h @@ -3,63 +3,63 @@ #include "CoreMinimal.h" #include "Misc/DateTime.h" #include "UObject/Object.h" -#include "RSHWNetworkType.h" -#include "RSHWNetworkClient.generated.h" +#include "RedNetworkType.h" +#include "RedNetworkClient.generated.h" class FKCPWrap; class FInternetAddr; UCLASS(BlueprintType) -class RSHWNETWORK_API URSHWNetworkClient : public UObject, public FTickableGameObject +class REDNETWORK_API URedNetworkClient : public UObject, public FTickableGameObject { GENERATED_BODY() public: - DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE(FLoginSignature, URSHWNetworkClient, OnLogin); - DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FRecvSignature, URSHWNetworkClient, OnRecv, const TArray&, Data); - DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE(FUnloginSignature, URSHWNetworkClient, OnUnlogin); + DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE(FLoginSignature, URedNetworkClient, OnLogin); + DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FRecvSignature, URedNetworkClient, OnRecv, const TArray&, Data); + DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE(FUnloginSignature, URedNetworkClient, OnUnlogin); public: - UPROPERTY(BlueprintAssignable, Category = "RSHW|Network") + UPROPERTY(BlueprintAssignable, Category = "Red|Network") FLoginSignature OnLogin; - UPROPERTY(BlueprintAssignable, Category = "RSHW|Network") + UPROPERTY(BlueprintAssignable, Category = "Red|Network") FRecvSignature OnRecv; - UPROPERTY(BlueprintAssignable, Category = "RSHW|Network") + UPROPERTY(BlueprintAssignable, Category = "Red|Network") FUnloginSignature OnUnlogin; public: - UFUNCTION(BlueprintCallable, Category = "RSHW|Network") + UFUNCTION(BlueprintCallable, Category = "Red|Network") bool IsActive() const { return bIsActive; } - UFUNCTION(BlueprintCallable, Category = "RSHW|Network") + UFUNCTION(BlueprintCallable, Category = "Red|Network") void Activate(bool bReset = false); - UFUNCTION(BlueprintCallable, Category = "RSHW|Network") + UFUNCTION(BlueprintCallable, Category = "Red|Network") void Deactivate(); - UFUNCTION(BlueprintCallable, Category = "RSHW|Network") + UFUNCTION(BlueprintCallable, Category = "Red|Network") bool IsLogged() const { return ClientPass.ID | ClientPass.Key; } - UFUNCTION(BlueprintCallable, Category = "RSHW|Network") + UFUNCTION(BlueprintCallable, Category = "Red|Network") bool Send(const TArray& Data); public: - UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network") + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network") FString ServerAddr = TEXT("127.0.0.1:25565"); - UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network") + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network") FTimespan Heartbeat = FTimespan::FromSeconds(1.0); - UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network") + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network") FTimespan TimeoutLimit = FTimespan::FromSeconds(8.0); - UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network") + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network") int32 KCPLogMask = 0; private: @@ -74,7 +74,7 @@ private: TArray RecvBuffer; TArray DataBuffer; - FRSHWNetworkPass ClientPass; + FRedNetworkPass ClientPass; FDateTime LastRecvTime; FDateTime LastHeartbeat; diff --git a/Source/RSHWNetwork/Public/RSHWNetworkServer.h b/Source/RedNetwork/Public/RedNetworkServer.h similarity index 61% rename from Source/RSHWNetwork/Public/RSHWNetworkServer.h rename to Source/RedNetwork/Public/RedNetworkServer.h index 699c798..c73545d 100644 --- a/Source/RSHWNetwork/Public/RSHWNetworkServer.h +++ b/Source/RedNetwork/Public/RedNetworkServer.h @@ -3,60 +3,60 @@ #include "CoreMinimal.h" #include "Misc/DateTime.h" #include "UObject/Object.h" -#include "RSHWNetworkType.h" -#include "RSHWNetworkServer.generated.h" +#include "RedNetworkType.h" +#include "RedNetworkServer.generated.h" class FSocket; class FKCPWrap; UCLASS(BlueprintType) -class RSHWNETWORK_API URSHWNetworkServer : public UObject, public FTickableGameObject +class REDNETWORK_API URedNetworkServer : public UObject, public FTickableGameObject { GENERATED_BODY() public: - DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FLoginSignature, URSHWNetworkServer, OnLogin, int32, ClientID); - DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(FRecvSignature, URSHWNetworkServer, OnRecv, int32, ClientID, const TArray&, Data); - DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FUnloginSignature, URSHWNetworkServer, OnUnlogin, int32, ClientID); + DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FLoginSignature, URedNetworkServer, OnLogin, int32, ClientID); + DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(FRecvSignature, URedNetworkServer, OnRecv, int32, ClientID, const TArray&, Data); + DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FUnloginSignature, URedNetworkServer, OnUnlogin, int32, ClientID); public: - UPROPERTY(BlueprintAssignable, Category = "RSHW|Network") + UPROPERTY(BlueprintAssignable, Category = "Red|Network") FLoginSignature OnLogin; - UPROPERTY(BlueprintAssignable, Category = "RSHW|Network") + UPROPERTY(BlueprintAssignable, Category = "Red|Network") FRecvSignature OnRecv; - UPROPERTY(BlueprintAssignable, Category = "RSHW|Network") + UPROPERTY(BlueprintAssignable, Category = "Red|Network") FUnloginSignature OnUnlogin; public: - UFUNCTION(BlueprintCallable, Category = "RSHW|Network") + UFUNCTION(BlueprintCallable, Category = "Red|Network") bool IsActive() const { return bIsActive; } - UFUNCTION(BlueprintCallable, Category = "RSHW|Network") + UFUNCTION(BlueprintCallable, Category = "Red|Network") void Activate(bool bReset = false); - UFUNCTION(BlueprintCallable, Category = "RSHW|Network") + UFUNCTION(BlueprintCallable, Category = "Red|Network") void Deactivate(); - UFUNCTION(BlueprintCallable, Category = "RSHW|Network") + UFUNCTION(BlueprintCallable, Category = "Red|Network") bool Send(int32 ClientID, const TArray& Data); public: - UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network") + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network") int32 Port = 25565; - UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network") + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network") FTimespan Heartbeat = FTimespan::FromSeconds(1.0); - UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network") + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network") FTimespan TimeoutLimit = FTimespan::FromSeconds(8.0); - UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network") + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network") int32 KCPLogMask = 0; private: @@ -74,14 +74,14 @@ private: struct FPreRegistrationInfo { FDateTime Time; - FRSHWNetworkPass Pass; + FRedNetworkPass Pass; }; TMap PreRegistration; struct FRegistrationInfo { - FRSHWNetworkPass Pass; + FRedNetworkPass Pass; FDateTime RecvTime; FDateTime Heartbeat; TSharedPtr Addr; diff --git a/Source/RSHWNetwork/Public/RSHWNetworkType.h b/Source/RedNetwork/Public/RedNetworkType.h similarity index 64% rename from Source/RSHWNetwork/Public/RSHWNetworkType.h rename to Source/RedNetwork/Public/RedNetworkType.h index cec5989..dc36313 100644 --- a/Source/RSHWNetwork/Public/RSHWNetworkType.h +++ b/Source/RedNetwork/Public/RedNetworkType.h @@ -2,7 +2,7 @@ #include "CoreMinimal.h" -struct FRSHWNetworkPass +struct REDNETWORK_API FRedNetworkPass { int32 ID; int32 Key; diff --git a/Source/RSHWNetwork/RSHWNetwork.Build.cs b/Source/RedNetwork/RedNetwork.Build.cs similarity index 90% rename from Source/RSHWNetwork/RSHWNetwork.Build.cs rename to Source/RedNetwork/RedNetwork.Build.cs index 0c9d98f..814f06a 100644 --- a/Source/RSHWNetwork/RSHWNetwork.Build.cs +++ b/Source/RedNetwork/RedNetwork.Build.cs @@ -2,9 +2,9 @@ using UnrealBuildTool; -public class RSHWNetwork : ModuleRules +public class RedNetwork : ModuleRules { - public RSHWNetwork(ReadOnlyTargetRules Target) : base(Target) + public RedNetwork(ReadOnlyTargetRules Target) : base(Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;