-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
Plugins/SimpleNetworkFunctions/SimpleNetworkFunctions.uplugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"FileVersion": 3, | ||
"Version": 1, | ||
"VersionName": "1.0", | ||
"FriendlyName": "Simple Network Functions", | ||
"Description": "This simple Unreal Engine plugin allows obtaining the player's local IP address during the game.", | ||
"Category": "Networking", | ||
"CreatedBy": "Sebastian Legieziński", | ||
"CreatedByURL": "https://github.com/seba0456/", | ||
"DocsURL": "", | ||
"MarketplaceURL": "", | ||
"SupportURL": "", | ||
"CanContainContent": true, | ||
"IsBetaVersion": true, | ||
"IsExperimentalVersion": false, | ||
"Installed": false, | ||
"Modules": [ | ||
{ | ||
"Name": "SimpleNetworkFunctions", | ||
"Type": "Runtime", | ||
"LoadingPhase": "Default", | ||
"WhitelistPlatforms": ["Win64"] | ||
} | ||
] | ||
} |
33 changes: 33 additions & 0 deletions
33
Plugins/SimpleNetworkFunctions/Source/SimpleNetworkFunctions/Private/MyNetworkFunctions.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright Sebastian Legieziński 2023 | ||
|
||
#include "MyNetworkFunctions.h" | ||
#include "Sockets.h" | ||
#include "SocketSubsystem.h" | ||
#include "IPAddress.h" | ||
|
||
|
||
FString UMyNetworkFunctions::GetLocalIPAddress() | ||
{ | ||
bool canBind = false; | ||
TSharedPtr<FInternetAddr> localIp = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->GetLocalHostAddr(*GLog, canBind); | ||
return (localIp->IsValid() ? localIp->ToString(false) : ""); | ||
} | ||
|
||
bool UMyNetworkFunctions::IsLanConnected() | ||
{ | ||
bool canBind = false; | ||
TSharedPtr<FInternetAddr> localIp = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->GetLocalHostAddr(*GLog, canBind); | ||
|
||
if (localIp.IsValid() && GetLocalIPAddress() != "") | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
|
||
|
||
|
20 changes: 20 additions & 0 deletions
20
...s/SimpleNetworkFunctions/Source/SimpleNetworkFunctions/Private/SimpleNetworkFunctions.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright Sebastian Legieziński 2023 | ||
|
||
#include "SimpleNetworkFunctions.h" | ||
|
||
#define LOCTEXT_NAMESPACE "FSimpleNetworkFunctionsModule" | ||
|
||
void FSimpleNetworkFunctionsModule::StartupModule() | ||
{ | ||
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module | ||
} | ||
|
||
void FSimpleNetworkFunctionsModule::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. | ||
} | ||
|
||
#undef LOCTEXT_NAMESPACE | ||
|
||
IMPLEMENT_MODULE(FSimpleNetworkFunctionsModule, SimpleNetworkFunctions) |
26 changes: 26 additions & 0 deletions
26
Plugins/SimpleNetworkFunctions/Source/SimpleNetworkFunctions/Public/MyNetworkFunctions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
#include "Kismet/BlueprintFunctionLibrary.h" | ||
#include "MyNetworkFunctions.generated.h" | ||
|
||
|
||
UCLASS() | ||
class SIMPLENETWORKFUNCTIONS_API UMyNetworkFunctions : public UBlueprintFunctionLibrary | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
/** | ||
* Function that returns LAN IP addres | ||
*/ | ||
UFUNCTION(BlueprintCallable, Category = "Networking", meta = (DisplayName = "Get LAN IP address", Description = "Function that returns LAN IP addres")) | ||
static FString GetLocalIPAddress(); | ||
|
||
/** | ||
* A function that returns a bool whether the system is connected to LAN. | ||
*/ | ||
UFUNCTION(BlueprintCallable, Category = "Networking", meta = (DisplayName = "Is connected to LAN?", Description="A function that returns a bool whether the system is connected to LAN.")) | ||
static bool IsLanConnected(); | ||
|
||
}; |
15 changes: 15 additions & 0 deletions
15
Plugins/SimpleNetworkFunctions/Source/SimpleNetworkFunctions/Public/SimpleNetworkFunctions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright Sebastian Legieziński 2023 | ||
|
||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
#include "Modules/ModuleManager.h" | ||
|
||
class FSimpleNetworkFunctionsModule : public IModuleInterface | ||
{ | ||
public: | ||
|
||
/** IModuleInterface implementation */ | ||
virtual void StartupModule() override; | ||
virtual void ShutdownModule() override; | ||
}; |
13 changes: 13 additions & 0 deletions
13
Plugins/SimpleNetworkFunctions/Source/SimpleNetworkFunctions/SimpleNetworkFunctions.Build.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using UnrealBuildTool; | ||
|
||
public class SimpleNetworkFunctions : ModuleRules | ||
{ | ||
public SimpleNetworkFunctions(ReadOnlyTargetRules Target) : base(Target) | ||
{ | ||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; | ||
|
||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine" }); | ||
|
||
PrivateDependencyModuleNames.AddRange(new string[] { "Sockets", "Networking" }); | ||
} | ||
} |