@d-healey said in HEADS UP: Server.downloadFile() issue on macOS Sequoia - and a solution:
I bet ChatGPT knows the magic spell for Windows too, I'll ask it tomorrow if you don't get there first :)
Hah, sure, but I'm too lazy to go test it right now.
So here's the reply :
One-shot check (returns Boolean, no packets sent)
$nlm = [Activator]::CreateInstance([type]'Microsoft.Windows.NetworkList.NetworkListManager')
$nlm.IsConnectedToInternet # $true = online, $false = offline
Continuous monitoring (no polling)
$nlm = [Activator]::CreateInstance([type]'Microsoft.Windows.NetworkList.NetworkListManager')
Register-ObjectEvent -InputObject $nlm `
-EventName 'ConnectivityChanged' `
-SourceIdentifier NLM `
-Action {
if ($Event.SourceEventArgs.IsConnectedToInternet) {
Write-Host 'online'
} else {
Write-Host 'offline'
}
}
# keep the session alive
while ($true) { Start-Sleep -Seconds 3600 }
HISE-native integration of this might be better than manually launching Background Task as then it can just start a process and every instance of the plugin can read from the process instead of having every plugin instance start its own monitoring process through BackgroundTask (as I don't think BackgroundTask can connect to an existing one?)