Working on version 2 of the MQTT client.
This commit is contained in:
@@ -87,3 +87,41 @@ extension EventLoopFuture where Value == (Temperature, RelativeHumidity) {
|
||||
map { .init(dryBulb: $0, humidity: $1, units: units) }
|
||||
}
|
||||
}
|
||||
|
||||
public struct Client2 {
|
||||
|
||||
/// Add the publish listeners to the MQTT Broker, to be notified of published changes.
|
||||
public var addListeners: () -> Void
|
||||
|
||||
/// Connect to the MQTT Broker.
|
||||
public var connect: () -> EventLoopFuture<Void>
|
||||
|
||||
public var publishSensor: (SensorPublishRequest) -> EventLoopFuture<Void>
|
||||
|
||||
/// Subscribe to appropriate topics / events.
|
||||
public var subscribe: () -> EventLoopFuture<Void>
|
||||
|
||||
/// Disconnect and close the connection to the MQTT Broker.
|
||||
public var shutdown: () -> EventLoopFuture<Void>
|
||||
|
||||
public init(
|
||||
addListeners: @escaping () -> Void,
|
||||
connect: @escaping () -> EventLoopFuture<Void>,
|
||||
publishSensor: @escaping (SensorPublishRequest) -> EventLoopFuture<Void>,
|
||||
shutdown: @escaping () -> EventLoopFuture<Void>,
|
||||
subscribe: @escaping () -> EventLoopFuture<Void>
|
||||
) {
|
||||
self.addListeners = addListeners
|
||||
self.connect = connect
|
||||
self.publishSensor = publishSensor
|
||||
self.shutdown = shutdown
|
||||
self.subscribe = subscribe
|
||||
}
|
||||
|
||||
public enum SensorPublishRequest {
|
||||
case mixed(State.Sensors.TemperatureHumiditySensor<State.Sensors.Mixed>)
|
||||
case postCoil(State.Sensors.TemperatureHumiditySensor<State.Sensors.PostCoil>)
|
||||
case `return`(State.Sensors.TemperatureHumiditySensor<State.Sensors.Return>)
|
||||
case supply(State.Sensors.TemperatureHumiditySensor<State.Sensors.Supply>)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user