feat: introduce Network framework transport prototype - #22
Open
rchatham wants to merge 15 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR starts an internal migration toward a Network-framework-backed transport by introducing transport seams (session/browser/advertiser/assistant), a framework-neutral peer identity model, and a first-cut Network protocol/framing prototype—while keeping the existing public API MultipeerConnectivity-backed.
Changes:
- Introduces internal transport protocols + a factory to inject MultipeerConnectivity (now) and future Network-backed implementations.
- Adds
PeerIdentityand updatesPeerequality/hash/displayName to be identity-based. - Adds Network protocol primitives (Bonjour service naming, handshake, frame encoding/decoding) plus prototype Network transport/coordinator/registry utilities and associated unit tests.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/PeerSession.swift | Makes PeerSession conform to PeerSessionTransport and exposes multipeerSession. |
| Sources/PeerConnectionManager.swift | Switches internals to transport protocols and adds an injectable transport factory initializer. |
| Sources/PeerConnectionTransports.swift | Adds internal transport protocols and a MultipeerConnectivity-backed factory. |
| Sources/PeerBrowser.swift | Uses PeerSessionTransport and routes invites via multipeerSession. |
| Sources/PeerAdvertiser.swift | Uses PeerSessionTransport for advertiser construction. |
| Sources/PeerAdvertiserAssisstant.swift | Uses PeerSessionTransport and routes assistant session via multipeerSession. |
| Sources/PeerAdvertiserEventProducer.swift | Updates invitation handler to operate on PeerSessionTransport. |
| Sources/PeerIdentity.swift | Adds framework-neutral PeerIdentity. |
| Sources/Peer.swift | Refactors displayName/equality/hash to be identity-based; adds MCPeerID→PeerIdentity mapping. |
| Sources/PeerNetworkProtocol.swift | Adds Bonjour service mapping, handshake model, framing, and streaming decoder. |
| Sources/NetworkPeerTransport.swift | Adds NWConnection/NWListener/NWBrowser wrappers (prototype). |
| Sources/NetworkPeerStateMapping.swift | Adds mapping helpers from NWConnection.State to Peer.Status semantics. |
| Sources/NetworkPeerConnectionRegistry.swift | Adds a registry with duplicate-connection resolution. |
| Sources/NetworkPeerDataSender.swift | Adds a data sender for framed sends over registry connections. |
| Sources/NetworkPeerCoordinator.swift | Adds handshake/data/discovery coordination + event emission into existing Observables. |
| PeerConnectivityTests/PeerIdentityTests.swift | Tests identity-backed Peer displayName/equality semantics. |
| PeerConnectivityTests/PeerNetworkProtocolTests.swift | Tests Bonjour naming, handshake encoding, frame encode/decode, streaming decoder behavior. |
| PeerConnectivityTests/PeerConnectionManagerTransportTests.swift | Verifies manager behavior via injected transport mocks. |
| PeerConnectivityTests/NetworkPeerStateMappingTests.swift | Tests state→status mapping utilities. |
| PeerConnectivityTests/NetworkPeerConnectionRegistryTests.swift | Tests duplicate resolution and cancellation behavior. |
| PeerConnectivityTests/NetworkPeerDataSenderTests.swift | Tests broadcast/targeted sending over registry connections. |
| PeerConnectivityTests/NetworkPeerCoordinatorTests.swift | Tests handshake registration, data events, duplicate handling, and discovery filtering. |
| PeerConnectivity.xcodeproj/project.pbxproj | Adds new source and test files to Xcode project. |
| NetworkFrameworkMigrationPlan.md | Adds a migration plan document for moving toward Network framework. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
Introduce the framework-neutral seams and initial Network.framework transport prototype that anchor the migration while preserving the existing public API and MultipeerConnectivity-backed default behavior.
Changes
PeerIdentitywhile keepingPeersource-compatible.NWConnection,NWListener, andNWBrowsertransports with peer-to-peer enabled.Compatibility
This checkpoint does not publicly select the Network backend. Existing public behavior remains MultipeerConnectivity-backed.
multipeerSessionremains the largest public compatibility constraint for eventual MC removal.Verification
swift test— 110 tests passed locally after review fixes.Follow-ups
Public backend selection, TLS-PSK, lifecycle reliability, browser UX, parity decisions, production trust, and migration guidance are intentionally layered in later checkpoints.
Stack
master