Skip to content

Commit

Permalink
Merge pull request #16 from Tivoyagefeak/master
Browse files Browse the repository at this point in the history
Get Sender IP Address
  • Loading branch information
getnamo committed Mar 1, 2021
2 parents 7a51a92 + 205c4df commit f1d80b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Source/UDPWrapper/Private/UDPComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ void UUDPComponent::LinkupCallbacks()
{
OnReceiveSocketClosed.Broadcast(Port);
};
Native->OnReceivedBytes = [this](const TArray<uint8>& Data)
Native->OnReceivedBytes = [this](const TArray<uint8>& Data, const FString& Endpoint)
{
OnReceivedBytes.Broadcast(Data);
OnReceivedBytes.Broadcast(Data, Endpoint);
};
}

Expand Down Expand Up @@ -226,18 +226,18 @@ void FUDPNative::OpenReceiveSocket(const int32 InListenPort /*= 3002*/)
if (Settings.bReceiveDataOnGameThread)
{
//Pass the reference to be used on gamethread
AsyncTask(ENamedThreads::GameThread, [this, Data]()
AsyncTask(ENamedThreads::GameThread, [this, Data, Endpoint]()
{
//double check we're still bound on this thread
if (OnReceivedBytes)
{
OnReceivedBytes(Data);
OnReceivedBytes(Data, Endpoint.Address.ToString());
}
});
}
else
{
OnReceivedBytes(Data);
OnReceivedBytes(Data, Endpoint.Address.ToString());
}
});

Expand Down
4 changes: 2 additions & 2 deletions Source/UDPWrapper/Public/UDPComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class UDPWRAPPER_API FUDPNative
{
public:

TFunction<void(const TArray<uint8>&)> OnReceivedBytes;
TFunction<void(const TArray<uint8>&, const FString&)> OnReceivedBytes;
TFunction<void(int32 Port)> OnReceiveOpened;
TFunction<void(int32 Port)> OnReceiveClosed;
TFunction<void(int32 Port)> OnSendOpened;
Expand Down Expand Up @@ -94,7 +94,7 @@ class UDPWRAPPER_API FUDPNative
};

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FUDPSocketStateSignature, int32, Port);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FUDPMessageSignature, const TArray<uint8>&, Bytes);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FUDPMessageSignature, const TArray<uint8>&, Bytes, const FString, IPAddress);

UCLASS(ClassGroup = "Networking", meta = (BlueprintSpawnableComponent))
class UDPWRAPPER_API UUDPComponent : public UActorComponent
Expand Down

0 comments on commit f1d80b1

Please sign in to comment.