Repository navigation
Keep roles active during pairing and clean up removed roles - #204
Merged
Merged
Conversation
A server/activate that added pairing dropped its active_roles, stopped time sync and client/state, and blocked controller commands, including ones queued during a re-handshake.
There was a problem hiding this comment.
🟢 Approval recommended
Static review identified no blocking issues in the focused activation and cleanup changes, which include regression coverage; tests were not run.
No open issues 🎉
What changed in this PR
This PR fixes activation handling in the Sendspin SDK so pairing can coexist with active roles, while removed roles release their playback resources and cached state.
Changes:
- Preserve clock sync, state updates, and controller commands during pairing when their roles remain active.
- Stop playback when the player role is removed and discard cached state and pending metadata for removed roles.
- Add regression coverage and adjust pairing and encryption tests for shared activation handling.
| File | Description |
|---|---|
tests/unit/transport-rehandshake.test.ts |
Verify queued commands survive pairing when the controller role remains active. |
tests/unit/protocol-handler.test.ts |
Cover player shutdown and removed-role state cleanup. |
tests/unit/pairing.test.ts |
Adapt tests to the activation handler’s void return type. |
tests/unit/core.test.ts |
Verify state updates and controller commands remain available during pairing. |
tests/unit/core-encryption.test.ts |
Consume all activation replies to keep encryption nonces aligned. |
src/core/transport.ts |
Retain queued commands based on the active controller role. |
src/core/state-manager.ts |
Discard removed-role state and cancel pending metadata updates. |
src/core/protocol-handler.ts |
Remove pairing suspension and clean up deactivated roles. |
src/core/pairing.ts |
Stop treating pairing activation as an exclusively consumed message. |
src/core/core.ts |
Route activation messages to both protocol and pairing handlers. |
Review effort: Balanced
33 tasks done
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.
What does this implement/fix?
Starting a pairing attempt while the player was active stopped clock sync,
client/stateupdates and controller commands until pairing ended, and could leave the client with no active roles. Aserver/activatethat adds pairing now keeps the active roles, as the spec requires.Removing a role in
server/activatenow also cleans up after it. Removingplayer@v1stops output and clears the buffers, and removingmetadata@v1orcontroller@v1discards its cachedserver/stateand any pending metadata update.aiosendspin still stops playback before pairing for this client, since our
client/hellostill looks like an older client to it.Related issue or spec PR (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies