HubitatServer: Adds HubitatServer type and adds it to the multiplexer
This commit is contained in:
@@ -102,14 +102,7 @@ extension ServerMultiplex
|
||||
private func handleDevicesChanged(_ devicesChanged: [AnyDevice])
|
||||
{
|
||||
let newDevicesSet = Set<AnyDevice>(devicesChanged)
|
||||
|
||||
let additions = newDevicesSet.subtracting(self.devices)
|
||||
if additions.count > 0 {
|
||||
DispatchQueue.main.async {
|
||||
self.delegate?.serverMultiplex(self, didAddDevices: Array(additions))
|
||||
}
|
||||
}
|
||||
|
||||
let changed = newDevicesSet.filter { (device: AnyDevice) in
|
||||
if let existing = (devices.first { $0.hashValue == device.hashValue }) {
|
||||
return existing.state != device.state
|
||||
@@ -118,13 +111,19 @@ extension ServerMultiplex
|
||||
return false
|
||||
}
|
||||
|
||||
self.devices = self.devices.union(newDevicesSet)
|
||||
|
||||
if additions.count > 0 {
|
||||
DispatchQueue.main.async {
|
||||
self.delegate?.serverMultiplex(self, didAddDevices: Array(additions))
|
||||
}
|
||||
}
|
||||
|
||||
if changed.count > 0 {
|
||||
DispatchQueue.main.async {
|
||||
self.delegate?.serverMultiplex(self, devicesStateChanged: Array(changed))
|
||||
}
|
||||
}
|
||||
|
||||
self.devices = self.devices.union(newDevicesSet)
|
||||
}
|
||||
|
||||
private func handleError(_ error: Error)
|
||||
|
||||
Reference in New Issue
Block a user