feat: Add and document optional kadb-mdns module#26
Open
Flyfish233 wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new optional Kotlin Multiplatform module (kadb-mdns) that discovers ADB-related mDNS services (Android via NsdManager, JVM via JmDNS), and updates project/docs to publish and document its usage alongside the core kadb artifact.
Changes:
- Introduce new
:kadb-mdnsmodule with Android + JVM discovery implementations and a sharedStateFlow-based state model. - Add mDNS discovery documentation and update README/platform docs to reference the optional artifact and usage.
- Add dependency catalog entry for JmDNS and add unit tests for parsing, mapping, and registry behavior.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| settings.gradle.kts | Registers the new :kadb-mdns Gradle module. |
| README.md | Documents the optional mDNS artifact and shows Android/JVM usage snippets. |
| kadb-mdns/build.gradle.kts | Defines the new KMP module, dependencies, and Maven publishing coordinates. |
| gradle/libs.versions.toml | Adds JmDNS dependency coordinates/version. |
| docs/README.md | Adds mDNS doc entry to the docs index. |
| docs/platform.md | Notes optional mDNS discovery support and requirements per platform. |
| docs/mdns.md | New dedicated documentation page for mDNS discovery and lifecycle/state model. |
| kadb-mdns/src/commonMain/kotlin/com/flyfishxu/kadb/mdns/KadbMdns.kt | Defines the shared KadbMdns interface and lifecycle methods. |
| kadb-mdns/src/commonMain/kotlin/com/flyfishxu/kadb/mdns/MdnsConfig.kt | Introduces configuration for service types and IPv4 preference. |
| kadb-mdns/src/commonMain/kotlin/com/flyfishxu/kadb/mdns/MdnsDiscoveryState.kt | Shared state model for discovery results and status. |
| kadb-mdns/src/commonMain/kotlin/com/flyfishxu/kadb/mdns/MdnsEndpoint.kt | Shared endpoint model for discovered services. |
| kadb-mdns/src/commonMain/kotlin/com/flyfishxu/kadb/mdns/MdnsServiceType.kt | Enumerates supported ADB-related service types. |
| kadb-mdns/src/commonMain/kotlin/com/flyfishxu/kadb/mdns/MdnsStatus.kt | Shared discovery status enum. |
| kadb-mdns/src/commonMain/kotlin/com/flyfishxu/kadb/mdns/internal/MdnsRegistry.kt | Central state registry for upsert/remove and grouping into connect/pair lists. |
| kadb-mdns/src/commonMain/kotlin/com/flyfishxu/kadb/mdns/internal/MdnsServiceKey.kt | Registry keying for endpoints by name + service type. |
| kadb-mdns/src/commonMain/kotlin/com/flyfishxu/kadb/mdns/internal/MdnsServiceTypeParser.kt | Normalization/parsing utilities for service type strings. |
| kadb-mdns/src/androidMain/kotlin/com/flyfishxu/kadb/mdns/KadbMdnsAndroid.kt | Android discovery implementation using NsdManager and API-level branching. |
| kadb-mdns/src/androidMain/kotlin/com/flyfishxu/kadb/mdns/internal/AndroidDiscoveryListener.kt | Bridges NSD discovery events into the module callbacks. |
| kadb-mdns/src/androidMain/kotlin/com/flyfishxu/kadb/mdns/internal/AndroidResolveListener.kt | Handles pre-API-34 resolve callbacks. |
| kadb-mdns/src/androidMain/kotlin/com/flyfishxu/kadb/mdns/internal/AndroidServiceInfoCallback.kt | Handles API-34+ ServiceInfoCallback updates/lifecycle. |
| kadb-mdns/src/androidMain/kotlin/com/flyfishxu/kadb/mdns/internal/NsdServiceInfoMapper.kt | Maps resolved NSD info into MdnsEndpoint/keys with IPv4 preference. |
| kadb-mdns/src/jvmMain/kotlin/com/flyfishxu/kadb/mdns/KadbMdnsJvm.kt | JVM discovery implementation with backend abstraction and registry integration. |
| kadb-mdns/src/jvmMain/kotlin/com/flyfishxu/kadb/mdns/internal/JmDnsBackend.kt | Backend + event abstraction for JmDNS integration/testing. |
| kadb-mdns/src/jvmMain/kotlin/com/flyfishxu/kadb/mdns/internal/JmDnsEndpointMapper.kt | Maps resolved JmDNS service info to MdnsEndpoint. |
| kadb-mdns/src/jvmMain/kotlin/com/flyfishxu/kadb/mdns/internal/JmDnsServiceListener.kt | Adapts JmDNS ServiceListener to internal event callbacks. |
| kadb-mdns/src/jvmMain/kotlin/com/flyfishxu/kadb/mdns/internal/RealJmDnsBackend.kt | Real JmDNS backend, interface selection, and service type formatting. |
| kadb-mdns/src/commonTest/kotlin/com/flyfishxu/kadb/mdns/MdnsRegistryTest.kt | Tests registry grouping, remove behavior, and validation. |
| kadb-mdns/src/commonTest/kotlin/com/flyfishxu/kadb/mdns/MdnsServiceTypeParserTest.kt | Tests service type parsing/normalization. |
| kadb-mdns/src/jvmTest/kotlin/com/flyfishxu/kadb/mdns/JmDnsEndpointMapperTest.kt | Tests endpoint mapping and validation on JVM. |
| kadb-mdns/src/jvmTest/kotlin/com/flyfishxu/kadb/mdns/KadbMdnsJvmTest.kt | Tests JVM discovery wiring (listeners, publish/remove, stop cleanup). |
| kadb-mdns/src/jvmTest/kotlin/com/flyfishxu/kadb/mdns/internal/FakeJmDnsBackend.kt | Fake backend for deterministic JVM tests. |
| kadb-mdns/src/jvmTest/kotlin/com/flyfishxu/kadb/mdns/internal/JmDnsServiceTypeFormatterTest.kt | Tests service type formatting for JmDNS. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+10
to
+15
| internal fun String?.normalizeMdnsServiceType(): String = | ||
| this.orEmpty() | ||
| .trim() | ||
| .removeSuffix(".") | ||
| .removeSuffix(".local") | ||
| .lowercase() |
| val pairDevices = values.filter { it.serviceType == MdnsServiceType.TLS_PAIRING } | ||
| mutableState.value = MdnsDiscoveryState( | ||
| status = status, | ||
| loading = status != MdnsStatus.STOPPED && status != MdnsStatus.FAILED && values.isEmpty(), |
Comment on lines
+45
to
+49
| val interfaceBackends = runCatching { | ||
| eligibleInterfaceAddresses().map { address -> | ||
| RealJmDnsBackend(JmDNS.create(address)) | ||
| } | ||
| }.getOrElse { emptyList() } |
|
Nice to see it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.