yes, I need to connect with all devices with this service. I send a httpRequest and get some parameter from all devices. Then I create a dynamic ListView to show DeviceInformations like Devicename, temperature, lightstate...
i find out that all devices have hostname like
device.local
device-1.local
device-2.local
....
so I have the best results if search with a for_loop
private func fillHostName()
{
let number = 30
var counter = 0
self.hostNames.removeAll()
if newHostNames.count == 0 {
while counter < number {
if counter == 0
{
self.hostNames.append(String("device.local"))
}
else
{
self.hostNames.append(String("device-\(counter).local"))
}
counter += 1
}
}
else
{
self.hostNames = self.newHostNames
}
}
self.hostNames.forEach{ host in
self.getMeshInfo(from: host)
usleep(80000)
}
I know that is "stupid polling" but it works absolut perfekt on very fast.
is there a better way?
Topic:
App & System Services
SubTopic:
Networking
Tags: