|
|
@ -49,15 +49,15 @@ std::thread* oscThread; |
|
|
|
* UdpListeningReceiveSocket runs in a blocking loop. [RunUntilSigInt()]*/ |
|
|
|
void runOscThread(unsigned int port) |
|
|
|
{ |
|
|
|
thePacketListener = new ThePacketListener; |
|
|
|
if (!thePacketListener) |
|
|
|
thePacketListener = new ThePacketListener; |
|
|
|
|
|
|
|
if (sock) sock->~UdpListeningReceiveSocket(); |
|
|
|
sock = new UdpListeningReceiveSocket( |
|
|
|
IpEndpointName(IpEndpointName::ANY_ADDRESS, port), |
|
|
|
thePacketListener); |
|
|
|
sock->RunUntilSigInt(); //<<--- this is the loop
|
|
|
|
|
|
|
|
//Cleanup after sock exited the loop
|
|
|
|
sock = NULL; |
|
|
|
thePacketListener = NULL; |
|
|
|
sock->RunUntilSigInt(); //<<--- this is the loop
|
|
|
|
} |
|
|
|
|
|
|
|
/* DLL was loaded */ |
|
|
@ -69,9 +69,11 @@ BOOL APIENTRY DllMain( HMODULE hModule, |
|
|
|
switch (ul_reason_for_call) |
|
|
|
{ |
|
|
|
case DLL_PROCESS_ATTACH: |
|
|
|
break; |
|
|
|
case DLL_THREAD_ATTACH: |
|
|
|
break; |
|
|
|
case DLL_THREAD_DETACH: |
|
|
|
break; |
|
|
|
case DLL_PROCESS_DETACH: |
|
|
|
close(); |
|
|
|
break; |
|
|
@ -97,15 +99,16 @@ DLLEXPORT int open(HWND targetWindowHandle, unsigned int port) |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
DLLEXPORT int close() |
|
|
|
DLLEXPORT int close(unsigned int clearListeners) |
|
|
|
{ |
|
|
|
if (sock && sock->IsBound()) |
|
|
|
if (sock) |
|
|
|
{ |
|
|
|
sock->AsynchronousBreak(); |
|
|
|
} |
|
|
|
oscThread->join(); |
|
|
|
oscThread = NULL; |
|
|
|
hwnd = NULL; |
|
|
|
listeners.clear(); |
|
|
|
if (clearListeners) listeners.clear(); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
@ -168,7 +171,10 @@ DLLEXPORT int handleOscMsg(const osc::ReceivedMessage& m) |
|
|
|
|
|
|
|
if (!hwnd || !sock->IsBound()) |
|
|
|
{ |
|
|
|
OutputDebugString(L"handleOscMsg: Seems open() was not called yet...\r\n"); |
|
|
|
OutputDebugString(L"handleOscMsg: Seems open() was not called yet..."); |
|
|
|
if (!hwnd) OutputDebugString(L" (hwnd)"); |
|
|
|
if (!sock->IsBound()) OutputDebugString(L" (sock)"); |
|
|
|
OutputDebugString(L"\r\n"); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|