|
|
@ -63,11 +63,16 @@ void runOscThread(unsigned int port) |
|
|
|
thePacketListener = new ThePacketListener; |
|
|
|
|
|
|
|
if (sock) sock->~UdpListeningReceiveSocket(); |
|
|
|
sock = new UdpListeningReceiveSocket( |
|
|
|
IpEndpointName(IpEndpointName::ANY_ADDRESS, port), |
|
|
|
thePacketListener); |
|
|
|
|
|
|
|
sock->RunUntilSigInt(); //<<--- this is the loop
|
|
|
|
try { |
|
|
|
sock = new UdpListeningReceiveSocket( |
|
|
|
IpEndpointName(IpEndpointName::ANY_ADDRESS, port), |
|
|
|
thePacketListener); |
|
|
|
sock->RunUntilSigInt(); //<<--- this is the loop
|
|
|
|
} |
|
|
|
catch (std::runtime_error) |
|
|
|
{ |
|
|
|
OutputDebugString(L"Unable to open port!\r\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* DLL was loaded */ |
|
|
@ -100,11 +105,24 @@ DLLEXPORT int open(HWND targetWindowHandle, unsigned int port) |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
unsigned int timeout = 500; //timout for port opening, in ms
|
|
|
|
|
|
|
|
/*Store handle to Autohotkey window globally*/ |
|
|
|
hwnd = targetWindowHandle; |
|
|
|
/*Start OSC Thread*/ |
|
|
|
oscThread = new std::thread(runOscThread, port); |
|
|
|
|
|
|
|
while ((!sock || !sock->IsBound()) && timeout) |
|
|
|
{ |
|
|
|
timeout--; |
|
|
|
Sleep(1); |
|
|
|
} |
|
|
|
if (!sock || !sock->IsBound()) |
|
|
|
{ |
|
|
|
OutputDebugString(L"open: cannot open port!!\r\n"); |
|
|
|
return 2; |
|
|
|
} |
|
|
|
|
|
|
|
OutputDebugString(L"open: Opened.\r\n"); |
|
|
|
return 0; |
|
|
|
} |
|
|
|