Skip to content

Commit

Permalink
Show host ip address
Browse files Browse the repository at this point in the history
  • Loading branch information
PutawanDE committed Mar 25, 2024
1 parent 5d34efc commit 5abeb50
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Content/Core/UI/3D_Menu/Widgets/Characters_Widget.uasset
Git LFS file not shown
8 changes: 8 additions & 0 deletions Plugins/SimpleNetworkFunctions/Config/FilterPlugin.ini
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
3 changes: 3 additions & 0 deletions Plugins/SimpleNetworkFunctions/Resources/Icon128.png
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 Plugins/SimpleNetworkFunctions/SimpleNetworkFunctions.uplugin
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"]
}
]
}
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;
}
}




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)
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();

};
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;
};
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" });
}
}

0 comments on commit 5abeb50

Please sign in to comment.