diff --git a/OSC/Source/OSC/Private/OscModule.cpp b/OSC/Source/OSC/Private/OscModule.cpp index 22fc8af..9563fa9 100644 --- a/OSC/Source/OSC/Private/OscModule.cpp +++ b/OSC/Source/OSC/Private/OscModule.cpp @@ -105,7 +105,7 @@ public: uint32_t receivePort; if(UOscSettings::Parse(settings->ReceiveFrom, &receiveAddress, &receivePort)) { - _dispatcher->Listen(receiveAddress, receivePort); + _dispatcher->Listen(receiveAddress, receivePort, settings->MulticastLoopback); } else { diff --git a/OSC/Source/OSC/Private/OscSettings.cpp b/OSC/Source/OSC/Private/OscSettings.cpp index 0578c0b..bc14df7 100644 --- a/OSC/Source/OSC/Private/OscSettings.cpp +++ b/OSC/Source/OSC/Private/OscSettings.cpp @@ -6,6 +6,7 @@ UOscSettings::UOscSettings() : ReceiveFrom("8000"), + MulticastLoopback(true), _sendSocket(FUdpSocketBuilder(TEXT("OscSender")).Build()) { SendTargets.Add(TEXT("127.0.0.1:8000")); diff --git a/OSC/Source/OSC/Private/OscSettings.h b/OSC/Source/OSC/Private/OscSettings.h index 84b4a6a..b6b89d0 100644 --- a/OSC/Source/OSC/Private/OscSettings.h +++ b/OSC/Source/OSC/Private/OscSettings.h @@ -44,6 +44,9 @@ public: UPROPERTY(Config, EditAnywhere, Category=Input) TArray Inputs; + UPROPERTY(Config, EditAnywhere, Category=Network) + bool MulticastLoopback; + public: void InitSendTargets(); diff --git a/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp b/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp index 7c40908..662d064 100644 --- a/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp +++ b/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp @@ -25,7 +25,7 @@ UOscDispatcher * UOscDispatcher::Get() return UOscDispatcher::StaticClass()->GetDefaultObject(); } -void UOscDispatcher::Listen(FIPv4Address address, uint32_t port) +void UOscDispatcher::Listen(FIPv4Address address, uint32_t port, bool multicastLoopback) { if(_listening != std::make_pair(address, port)) { @@ -36,6 +36,10 @@ void UOscDispatcher::Listen(FIPv4Address address, uint32_t port) if(address.IsMulticastAddress()) { builder.JoinedToGroup(address); + if(multicastLoopback) + { + builder.WithMulticastLoopback(); + } } else { diff --git a/OSC/Source/OSC/Private/Receive/OscDispatcher.h b/OSC/Source/OSC/Private/Receive/OscDispatcher.h index 4673b92..9318261 100644 --- a/OSC/Source/OSC/Private/Receive/OscDispatcher.h +++ b/OSC/Source/OSC/Private/Receive/OscDispatcher.h @@ -16,7 +16,7 @@ class UOscDispatcher : public UObject friend class FOscModule; - void Listen(FIPv4Address address, uint32_t port); + void Listen(FIPv4Address address, uint32_t port, bool multicastLoopback); void Stop(); public: