重命名为 RedNetwork
This commit is contained in:
parent
d68d6eeec0
commit
859db61f9c
|
@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
#include "Logging.h"
|
|
||||||
|
|
||||||
DEFINE_LOG_CATEGORY(LogRSHWNetwork);
|
|
|
@ -1 +0,0 @@
|
||||||
#include "RSHWNetworkType.h"
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
#include "Logging.h"
|
||||||
|
|
||||||
|
DEFINE_LOG_CATEGORY(LogRedNetwork);
|
|
@ -3,4 +3,4 @@
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Modules/ModuleManager.h"
|
#include "Modules/ModuleManager.h"
|
||||||
|
|
||||||
DECLARE_LOG_CATEGORY_EXTERN(LogRSHWNetwork, Log, All);
|
DECLARE_LOG_CATEGORY_EXTERN(LogRedNetwork, Log, All);
|
|
@ -1,15 +1,15 @@
|
||||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
// 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
|
// 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,
|
// 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.
|
// we call this function before unloading the module.
|
||||||
|
@ -17,4 +17,4 @@ void FRSHWNetworkModule::ShutdownModule()
|
||||||
|
|
||||||
#undef LOCTEXT_NAMESPACE
|
#undef LOCTEXT_NAMESPACE
|
||||||
|
|
||||||
IMPLEMENT_MODULE(FRSHWNetworkModule, RSHWNetwork)
|
IMPLEMENT_MODULE(FRedNetworkModule, RedNetwork)
|
|
@ -1,4 +1,4 @@
|
||||||
#include "RSHWNetworkClient.h"
|
#include "RedNetworkClient.h"
|
||||||
|
|
||||||
#include "KCPWrap.h"
|
#include "KCPWrap.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
@ -6,14 +6,14 @@
|
||||||
#include "IPAddress.h"
|
#include "IPAddress.h"
|
||||||
#include "SocketSubsystem.h"
|
#include "SocketSubsystem.h"
|
||||||
|
|
||||||
bool URSHWNetworkClient::Send(const TArray<uint8>& Data)
|
bool URedNetworkClient::Send(const TArray<uint8>& Data)
|
||||||
{
|
{
|
||||||
if (!IsActive() || !(ClientPass.ID | ClientPass.Key)) return false;
|
if (!IsActive() || !(ClientPass.ID | ClientPass.Key)) return false;
|
||||||
|
|
||||||
return KCPUnit->Send(Data.GetData(), Data.Num());
|
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;
|
if (!IsActive() || !(ClientPass.ID | ClientPass.Key)) return false;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ int32 URSHWNetworkClient::UDPSend(const uint8 * Data, int32 Count)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void URSHWNetworkClient::Tick(float DeltaTime)
|
void URedNetworkClient::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
if (!IsActive()) return;
|
if (!IsActive()) return;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ void URSHWNetworkClient::Tick(float DeltaTime)
|
||||||
if (BytesRead < 8) continue;
|
if (BytesRead < 8) continue;
|
||||||
RecvBuffer.SetNumUninitialized(BytesRead, false);
|
RecvBuffer.SetNumUninitialized(BytesRead, false);
|
||||||
|
|
||||||
FRSHWNetworkPass SourcePass;
|
FRedNetworkPass SourcePass;
|
||||||
SourcePass.ID = 0;
|
SourcePass.ID = 0;
|
||||||
SourcePass.Key = 0;
|
SourcePass.Key = 0;
|
||||||
|
|
||||||
|
@ -167,14 +167,14 @@ void URSHWNetworkClient::Tick(float DeltaTime)
|
||||||
|
|
||||||
KCPUnit = nullptr;
|
KCPUnit = nullptr;
|
||||||
|
|
||||||
UE_LOG(LogRSHWNetwork, Warning, TEXT("RSHW Network Client timeout."));
|
UE_LOG(LogRedNetwork, Warning, TEXT("Red Network Client timeout."));
|
||||||
|
|
||||||
OnUnlogin.Broadcast();
|
OnUnlogin.Broadcast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void URSHWNetworkClient::Activate(bool bReset)
|
void URedNetworkClient::Activate(bool bReset)
|
||||||
{
|
{
|
||||||
if (bReset) Deactivate();
|
if (bReset) Deactivate();
|
||||||
if (bIsActive) return;
|
if (bIsActive) return;
|
||||||
|
@ -183,7 +183,7 @@ void URSHWNetworkClient::Activate(bool bReset)
|
||||||
|
|
||||||
if (SocketSubsystem == nullptr)
|
if (SocketSubsystem == nullptr)
|
||||||
{
|
{
|
||||||
UE_LOG(LogRSHWNetwork, Error, TEXT("Socket subsystem is nullptr."));
|
UE_LOG(LogRedNetwork, Error, TEXT("Socket subsystem is nullptr."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,22 +195,22 @@ void URSHWNetworkClient::Activate(bool bReset)
|
||||||
|
|
||||||
if (!bIsValid)
|
if (!bIsValid)
|
||||||
{
|
{
|
||||||
UE_LOG(LogRSHWNetwork, Error, TEXT("Server addr invalid."));
|
UE_LOG(LogRedNetwork, Error, TEXT("Server addr invalid."));
|
||||||
ServerAddrPtr = nullptr;
|
ServerAddrPtr = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketPtr = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("RSHW Client Socket"));
|
SocketPtr = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("Red Client Socket"));
|
||||||
|
|
||||||
if (SocketPtr == nullptr)
|
if (SocketPtr == nullptr)
|
||||||
{
|
{
|
||||||
UE_LOG(LogRSHWNetwork, Error, TEXT("Socket creation failed."));
|
UE_LOG(LogRedNetwork, Error, TEXT("Socket creation failed."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SocketPtr->SetNonBlocking())
|
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);
|
SocketSubsystem->DestroySocket(SocketPtr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,12 @@ void URSHWNetworkClient::Activate(bool bReset)
|
||||||
ClientPass.Key = 0;
|
ClientPass.Key = 0;
|
||||||
LastRecvTime = FDateTime::Now();
|
LastRecvTime = FDateTime::Now();
|
||||||
LastHeartbeat = FDateTime::MinValue();
|
LastHeartbeat = FDateTime::MinValue();
|
||||||
UE_LOG(LogRSHWNetwork, Log, TEXT("RSHW Network Client activate."));
|
UE_LOG(LogRedNetwork, Log, TEXT("Red Network Client activate."));
|
||||||
|
|
||||||
bIsActive = true;
|
bIsActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void URSHWNetworkClient::Deactivate()
|
void URedNetworkClient::Deactivate()
|
||||||
{
|
{
|
||||||
if (!bIsActive) return;
|
if (!bIsActive) return;
|
||||||
|
|
||||||
|
@ -246,12 +246,12 @@ void URSHWNetworkClient::Deactivate()
|
||||||
|
|
||||||
KCPUnit = nullptr;
|
KCPUnit = nullptr;
|
||||||
|
|
||||||
UE_LOG(LogRSHWNetwork, Log, TEXT("RSHW Network Client deactivate."));
|
UE_LOG(LogRedNetwork, Log, TEXT("Red Network Client deactivate."));
|
||||||
|
|
||||||
bIsActive = false;
|
bIsActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void URSHWNetworkClient::BeginDestroy()
|
void URedNetworkClient::BeginDestroy()
|
||||||
{
|
{
|
||||||
Deactivate();
|
Deactivate();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "RSHWNetworkServer.h"
|
#include "RedNetworkServer.h"
|
||||||
|
|
||||||
#include "KCPWrap.h"
|
#include "KCPWrap.h"
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
#include "SocketSubsystem.h"
|
#include "SocketSubsystem.h"
|
||||||
#include "HAL/UnrealMemory.h"
|
#include "HAL/UnrealMemory.h"
|
||||||
|
|
||||||
bool URSHWNetworkServer::Send(int32 ClientID, const TArray<uint8>& Data)
|
bool URedNetworkServer::Send(int32 ClientID, const TArray<uint8>& Data)
|
||||||
{
|
{
|
||||||
if (!IsActive() || !Registration.Contains(ClientID)) return false;
|
if (!IsActive() || !Registration.Contains(ClientID)) return false;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ bool URSHWNetworkServer::Send(int32 ClientID, const TArray<uint8>& Data)
|
||||||
return !Info.KCPUnit->Send(Data.GetData(), Data.Num());
|
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;
|
if (!IsActive() || !Registration.Contains(ClientID)) return false;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ int32 URSHWNetworkServer::UDPSend(int32 ClientID, const uint8* Data, int32 Count
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void URSHWNetworkServer::Tick(float DeltaTime)
|
void URedNetworkServer::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
if (!IsActive()) return;
|
if (!IsActive()) return;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ void URSHWNetworkServer::Tick(float DeltaTime)
|
||||||
if (BytesRead < 8) continue;
|
if (BytesRead < 8) continue;
|
||||||
RecvBuffer.SetNumUninitialized(BytesRead, false);
|
RecvBuffer.SetNumUninitialized(BytesRead, false);
|
||||||
|
|
||||||
FRSHWNetworkPass SourcePass;
|
FRedNetworkPass SourcePass;
|
||||||
SourcePass.ID = 0;
|
SourcePass.ID = 0;
|
||||||
SourcePass.Key = 0;
|
SourcePass.Key = 0;
|
||||||
|
|
||||||
|
@ -138,10 +138,10 @@ void URSHWNetworkServer::Tick(float DeltaTime)
|
||||||
|
|
||||||
PreRegistration.Add(SourceAddrStr, NewRegistration);
|
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);
|
SendBuffer.SetNum(8, false);
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ void URSHWNetworkServer::Tick(float DeltaTime)
|
||||||
int32 BytesSend;
|
int32 BytesSend;
|
||||||
if (SocketPtr->SendTo(SendBuffer.GetData(), SendBuffer.Num(), BytesSend, *SourceAddr) && BytesSend == SendBuffer.Num())
|
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
|
else
|
||||||
|
@ -170,7 +170,7 @@ void URSHWNetworkServer::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Registration[SourcePass.ID].Addr = SourceAddr;
|
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);
|
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);
|
OnLogin.Broadcast(SourcePass.ID);
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ void URSHWNetworkServer::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
if (NowTime - PreRegistration[Addr].Time > TimeoutLimit)
|
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);
|
PreRegistration.Remove(Addr);
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ void URSHWNetworkServer::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
if (NowTime - Registration[ID].RecvTime > TimeoutLimit)
|
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);
|
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 (bReset) Deactivate();
|
||||||
if (bIsActive) return;
|
if (bIsActive) return;
|
||||||
|
@ -300,15 +300,15 @@ void URSHWNetworkServer::Activate(bool bReset)
|
||||||
|
|
||||||
if (SocketSubsystem == nullptr)
|
if (SocketSubsystem == nullptr)
|
||||||
{
|
{
|
||||||
UE_LOG(LogRSHWNetwork, Error, TEXT("Socket subsystem is nullptr."));
|
UE_LOG(LogRedNetwork, Error, TEXT("Socket subsystem is nullptr."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketPtr = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("RSHW Server Socket"));
|
SocketPtr = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("Red Server Socket"));
|
||||||
|
|
||||||
if (SocketPtr == nullptr)
|
if (SocketPtr == nullptr)
|
||||||
{
|
{
|
||||||
UE_LOG(LogRSHWNetwork, Error, TEXT("Socket creation failed."));
|
UE_LOG(LogRedNetwork, Error, TEXT("Socket creation failed."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,26 +319,26 @@ void URSHWNetworkServer::Activate(bool bReset)
|
||||||
|
|
||||||
if (!SocketPtr->Bind(*ServerAddr))
|
if (!SocketPtr->Bind(*ServerAddr))
|
||||||
{
|
{
|
||||||
UE_LOG(LogRSHWNetwork, Error, TEXT("Socket bind failed."));
|
UE_LOG(LogRedNetwork, Error, TEXT("Socket bind failed."));
|
||||||
SocketSubsystem->DestroySocket(SocketPtr);
|
SocketSubsystem->DestroySocket(SocketPtr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SocketPtr->SetNonBlocking())
|
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);
|
SocketSubsystem->DestroySocket(SocketPtr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NextRegistrationID = 1;
|
NextRegistrationID = 1;
|
||||||
|
|
||||||
UE_LOG(LogRSHWNetwork, Log, TEXT("RSHW Network Server activate."));
|
UE_LOG(LogRedNetwork, Log, TEXT("Red Network Server activate."));
|
||||||
|
|
||||||
bIsActive = true;
|
bIsActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void URSHWNetworkServer::Deactivate()
|
void URedNetworkServer::Deactivate()
|
||||||
{
|
{
|
||||||
if (!bIsActive) return;
|
if (!bIsActive) return;
|
||||||
|
|
||||||
|
@ -361,12 +361,12 @@ void URSHWNetworkServer::Deactivate()
|
||||||
PreRegistration.Reset();
|
PreRegistration.Reset();
|
||||||
Registration.Reset();
|
Registration.Reset();
|
||||||
|
|
||||||
UE_LOG(LogRSHWNetwork, Log, TEXT("RSHW Network Server deactivate."));
|
UE_LOG(LogRedNetwork, Log, TEXT("Red Network Server deactivate."));
|
||||||
|
|
||||||
bIsActive = false;
|
bIsActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void URSHWNetworkServer::BeginDestroy()
|
void URedNetworkServer::BeginDestroy()
|
||||||
{
|
{
|
||||||
Deactivate();
|
Deactivate();
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
#include "RedNetworkType.h"
|
|
@ -5,7 +5,7 @@
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Modules/ModuleManager.h"
|
#include "Modules/ModuleManager.h"
|
||||||
|
|
||||||
class FRSHWNetworkModule : public IModuleInterface
|
class FRedNetworkModule : public IModuleInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -3,63 +3,63 @@
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Misc/DateTime.h"
|
#include "Misc/DateTime.h"
|
||||||
#include "UObject/Object.h"
|
#include "UObject/Object.h"
|
||||||
#include "RSHWNetworkType.h"
|
#include "RedNetworkType.h"
|
||||||
#include "RSHWNetworkClient.generated.h"
|
#include "RedNetworkClient.generated.h"
|
||||||
|
|
||||||
class FKCPWrap;
|
class FKCPWrap;
|
||||||
class FInternetAddr;
|
class FInternetAddr;
|
||||||
|
|
||||||
UCLASS(BlueprintType)
|
UCLASS(BlueprintType)
|
||||||
class RSHWNETWORK_API URSHWNetworkClient : public UObject, public FTickableGameObject
|
class REDNETWORK_API URedNetworkClient : public UObject, public FTickableGameObject
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE(FLoginSignature, URSHWNetworkClient, OnLogin);
|
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE(FLoginSignature, URedNetworkClient, OnLogin);
|
||||||
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FRecvSignature, URSHWNetworkClient, OnRecv, const TArray<uint8>&, Data);
|
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FRecvSignature, URedNetworkClient, OnRecv, const TArray<uint8>&, Data);
|
||||||
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE(FUnloginSignature, URSHWNetworkClient, OnUnlogin);
|
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE(FUnloginSignature, URedNetworkClient, OnUnlogin);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable, Category = "RSHW|Network")
|
UPROPERTY(BlueprintAssignable, Category = "Red|Network")
|
||||||
FLoginSignature OnLogin;
|
FLoginSignature OnLogin;
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable, Category = "RSHW|Network")
|
UPROPERTY(BlueprintAssignable, Category = "Red|Network")
|
||||||
FRecvSignature OnRecv;
|
FRecvSignature OnRecv;
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable, Category = "RSHW|Network")
|
UPROPERTY(BlueprintAssignable, Category = "Red|Network")
|
||||||
FUnloginSignature OnUnlogin;
|
FUnloginSignature OnUnlogin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "RSHW|Network")
|
UFUNCTION(BlueprintCallable, Category = "Red|Network")
|
||||||
bool IsActive() const { return bIsActive; }
|
bool IsActive() const { return bIsActive; }
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "RSHW|Network")
|
UFUNCTION(BlueprintCallable, Category = "Red|Network")
|
||||||
void Activate(bool bReset = false);
|
void Activate(bool bReset = false);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "RSHW|Network")
|
UFUNCTION(BlueprintCallable, Category = "Red|Network")
|
||||||
void Deactivate();
|
void Deactivate();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "RSHW|Network")
|
UFUNCTION(BlueprintCallable, Category = "Red|Network")
|
||||||
bool IsLogged() const { return ClientPass.ID | ClientPass.Key; }
|
bool IsLogged() const { return ClientPass.ID | ClientPass.Key; }
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "RSHW|Network")
|
UFUNCTION(BlueprintCallable, Category = "Red|Network")
|
||||||
bool Send(const TArray<uint8>& Data);
|
bool Send(const TArray<uint8>& Data);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network")
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network")
|
||||||
FString ServerAddr = TEXT("127.0.0.1:25565");
|
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);
|
FTimespan Heartbeat = FTimespan::FromSeconds(1.0);
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network")
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network")
|
||||||
FTimespan TimeoutLimit = FTimespan::FromSeconds(8.0);
|
FTimespan TimeoutLimit = FTimespan::FromSeconds(8.0);
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network")
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network")
|
||||||
int32 KCPLogMask = 0;
|
int32 KCPLogMask = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -74,7 +74,7 @@ private:
|
||||||
TArray<uint8> RecvBuffer;
|
TArray<uint8> RecvBuffer;
|
||||||
TArray<uint8> DataBuffer;
|
TArray<uint8> DataBuffer;
|
||||||
|
|
||||||
FRSHWNetworkPass ClientPass;
|
FRedNetworkPass ClientPass;
|
||||||
|
|
||||||
FDateTime LastRecvTime;
|
FDateTime LastRecvTime;
|
||||||
FDateTime LastHeartbeat;
|
FDateTime LastHeartbeat;
|
|
@ -3,60 +3,60 @@
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Misc/DateTime.h"
|
#include "Misc/DateTime.h"
|
||||||
#include "UObject/Object.h"
|
#include "UObject/Object.h"
|
||||||
#include "RSHWNetworkType.h"
|
#include "RedNetworkType.h"
|
||||||
#include "RSHWNetworkServer.generated.h"
|
#include "RedNetworkServer.generated.h"
|
||||||
|
|
||||||
class FSocket;
|
class FSocket;
|
||||||
class FKCPWrap;
|
class FKCPWrap;
|
||||||
|
|
||||||
UCLASS(BlueprintType)
|
UCLASS(BlueprintType)
|
||||||
class RSHWNETWORK_API URSHWNetworkServer : public UObject, public FTickableGameObject
|
class REDNETWORK_API URedNetworkServer : public UObject, public FTickableGameObject
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FLoginSignature, URSHWNetworkServer, OnLogin, int32, ClientID);
|
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FLoginSignature, URedNetworkServer, OnLogin, int32, ClientID);
|
||||||
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(FRecvSignature, URSHWNetworkServer, OnRecv, int32, ClientID, const TArray<uint8>&, Data);
|
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_TwoParams(FRecvSignature, URedNetworkServer, OnRecv, int32, ClientID, const TArray<uint8>&, Data);
|
||||||
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FUnloginSignature, URSHWNetworkServer, OnUnlogin, int32, ClientID);
|
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FUnloginSignature, URedNetworkServer, OnUnlogin, int32, ClientID);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable, Category = "RSHW|Network")
|
UPROPERTY(BlueprintAssignable, Category = "Red|Network")
|
||||||
FLoginSignature OnLogin;
|
FLoginSignature OnLogin;
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable, Category = "RSHW|Network")
|
UPROPERTY(BlueprintAssignable, Category = "Red|Network")
|
||||||
FRecvSignature OnRecv;
|
FRecvSignature OnRecv;
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable, Category = "RSHW|Network")
|
UPROPERTY(BlueprintAssignable, Category = "Red|Network")
|
||||||
FUnloginSignature OnUnlogin;
|
FUnloginSignature OnUnlogin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "RSHW|Network")
|
UFUNCTION(BlueprintCallable, Category = "Red|Network")
|
||||||
bool IsActive() const { return bIsActive; }
|
bool IsActive() const { return bIsActive; }
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "RSHW|Network")
|
UFUNCTION(BlueprintCallable, Category = "Red|Network")
|
||||||
void Activate(bool bReset = false);
|
void Activate(bool bReset = false);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "RSHW|Network")
|
UFUNCTION(BlueprintCallable, Category = "Red|Network")
|
||||||
void Deactivate();
|
void Deactivate();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "RSHW|Network")
|
UFUNCTION(BlueprintCallable, Category = "Red|Network")
|
||||||
bool Send(int32 ClientID, const TArray<uint8>& Data);
|
bool Send(int32 ClientID, const TArray<uint8>& Data);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network")
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network")
|
||||||
int32 Port = 25565;
|
int32 Port = 25565;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network")
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network")
|
||||||
FTimespan Heartbeat = FTimespan::FromSeconds(1.0);
|
FTimespan Heartbeat = FTimespan::FromSeconds(1.0);
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network")
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network")
|
||||||
FTimespan TimeoutLimit = FTimespan::FromSeconds(8.0);
|
FTimespan TimeoutLimit = FTimespan::FromSeconds(8.0);
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "RSHW|Network")
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Red|Network")
|
||||||
int32 KCPLogMask = 0;
|
int32 KCPLogMask = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -74,14 +74,14 @@ private:
|
||||||
struct FPreRegistrationInfo
|
struct FPreRegistrationInfo
|
||||||
{
|
{
|
||||||
FDateTime Time;
|
FDateTime Time;
|
||||||
FRSHWNetworkPass Pass;
|
FRedNetworkPass Pass;
|
||||||
};
|
};
|
||||||
|
|
||||||
TMap<FString, FPreRegistrationInfo> PreRegistration;
|
TMap<FString, FPreRegistrationInfo> PreRegistration;
|
||||||
|
|
||||||
struct FRegistrationInfo
|
struct FRegistrationInfo
|
||||||
{
|
{
|
||||||
FRSHWNetworkPass Pass;
|
FRedNetworkPass Pass;
|
||||||
FDateTime RecvTime;
|
FDateTime RecvTime;
|
||||||
FDateTime Heartbeat;
|
FDateTime Heartbeat;
|
||||||
TSharedPtr<FInternetAddr> Addr;
|
TSharedPtr<FInternetAddr> Addr;
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
|
||||||
struct FRSHWNetworkPass
|
struct REDNETWORK_API FRedNetworkPass
|
||||||
{
|
{
|
||||||
int32 ID;
|
int32 ID;
|
||||||
int32 Key;
|
int32 Key;
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
using UnrealBuildTool;
|
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;
|
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||||
|
|
Loading…
Reference in New Issue