Skip to content

Commit f0b68dc

Browse files
committed
add addSubscriptions(events:) method to Ocp1Connection
1 parent 04122a9 commit f0b68dc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/SwiftOCA/OCP.1/Ocp1Connection+Subscribe.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ public extension Ocp1Connection {
138138
subscriptions.removeAll()
139139
}
140140

141-
internal func refreshSubscriptions() async {
141+
public func addSubscriptions(events: [OcaEvent]) async {
142142
await withTaskGroup(of: Void.self, returning: Void.self) { taskGroup in
143-
for event in subscriptions.keys {
143+
for event in events {
144144
taskGroup.addTask { [self] in
145145
try? await subscriptionManager.addSubscription(
146146
event: event,
@@ -154,6 +154,10 @@ public extension Ocp1Connection {
154154
}
155155
}
156156

157+
internal func refreshSubscriptions() async {
158+
await addSubscriptions(events: Array(subscriptions.keys))
159+
}
160+
157161
internal func notifySubscribers(of event: OcaEvent, with parameters: Data) {
158162
guard let eventSubscriptions = subscriptions[event],
159163
!eventSubscriptions.subscriptions.isEmpty

0 commit comments

Comments
 (0)