Skip to content

Commit 9bd3514

Browse files
committed
dns_sd support for service browsing, on non-Darwin platforms
1 parent f9189ad commit 9bd3514

File tree

3 files changed

+438
-3
lines changed

3 files changed

+438
-3
lines changed

Examples/OCABrokerTest/BrokerTest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private let connectionOptions = Ocp1ConnectionOptions(flags: [
2626
@main
2727
public enum BrokerTest {
2828
public static func main() async throws {
29-
#if canImport(Darwin)
29+
#if canImport(Darwin) || canImport(dnssd)
3030
let broker = await OcaConnectionBroker(connectionOptions: connectionOptions)
3131
print("waiting for events from broker...")
3232
for try await event in await broker.events {
@@ -40,7 +40,7 @@ public enum BrokerTest {
4040
}
4141
print("done!")
4242
#else
43-
preconditionFailure("OcaConnectionBroker not yet supported on non-Darwin platforms")
43+
preconditionFailure("OcaConnectionBroker not available on this platform")
4444
#endif
4545
}
4646
}

Sources/SwiftOCA/OCA/Browsing/ConnectionBroker.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// limitations under the License.
1515
//
1616

17-
#if canImport(Darwin)
17+
#if canImport(Darwin) || canImport(dnssd)
1818

1919
import AsyncAlgorithms
2020
import AsyncExtensions
@@ -224,7 +224,11 @@ public actor OcaConnectionBroker {
224224
var browserMonitor: Task<(), Error>?
225225

226226
init(serviceType: OcaNetworkAdvertisingServiceType, broker: OcaConnectionBroker) throws {
227+
#if canImport(dnssd)
228+
browser = try OcaDNSServiceBrowser(serviceType: serviceType)
229+
#else
227230
browser = try OcaNetServiceBrowser(serviceType: serviceType)
231+
#endif
228232
Task { try await browser.start() }
229233
browserMonitor = Task { [weak broker] in
230234
for try await result in browser.browseResults {

0 commit comments

Comments
 (0)