Skip to content

Commit a72b689

Browse files
committed
OcaConnectionBroker: allow filtering of service types
1 parent f9189ad commit a72b689

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Sources/SwiftOCA/OCA/Browsing/ConnectionBroker.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ public actor OcaConnectionBroker {
239239
}
240240
}
241241

242+
private static let _defaultServiceTypes = Set([
243+
OcaNetworkAdvertisingServiceType.tcp,
244+
OcaNetworkAdvertisingServiceType.udp,
245+
])
246+
242247
/// An async sequence of events emitted by the connection broker.
243248
///
244249
/// This sequence provides notifications about device lifecycle changes and connection state
@@ -316,12 +321,13 @@ public actor OcaConnectionBroker {
316321
///
317322
/// - Parameter connectionOptions: Configuration options for connections created by this broker.
318323
/// Defaults to standard options if not specified.
319-
public init(connectionOptions: Ocp1ConnectionOptions = .init()) {
324+
public init(
325+
connectionOptions: Ocp1ConnectionOptions = .init(),
326+
serviceTypes: Set<OcaNetworkAdvertisingServiceType>? = nil
327+
) {
320328
_connectionOptions = connectionOptions
321329
var browsers = [OcaNetworkAdvertisingServiceType: BrowserMonitor]()
322-
for serviceType in [OcaNetworkAdvertisingServiceType.tcp,
323-
OcaNetworkAdvertisingServiceType.udp]
324-
{
330+
for serviceType in serviceTypes ?? Self._defaultServiceTypes {
325331
browsers[serviceType] = try! BrowserMonitor(serviceType: serviceType, broker: self)
326332
}
327333
_browsers = browsers

0 commit comments

Comments
 (0)