Refactor Connect/Disconnect out to CClient with an explicit connection state#3805
Open
mcfnord wants to merge 2 commits into
Open
Refactor Connect/Disconnect out to CClient with an explicit connection state#3805mcfnord wants to merge 2 commits into
mcfnord wants to merge 2 commits into
Conversation
This is an extract from jamulussoftware#2550 Co-authored-by: ann0see <20726856+ann0see@users.noreply.github.com>
Introduce EConnectionState (disconnected / connecting / connected) owned by CClient as the single source of truth. A connection is 'requested' when the audio stream starts (CS_CONNECTING) and 'established' once the server assigns our channel ID (CS_CONNECTED). Every transition emits ConnectionStateChanged. Rename the Connected(name) signal emitted from Start() to Connecting(name), since at that point the connection is only requested, not established. CClient::Connect() now terminates any current connection first, so connecting while connected behaves as a reconnect. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5 tasks
mcfnord
marked this pull request as ready for review
July 19, 2026 02:25
Member
|
Thanks. This needs thorough testing as this refactor is definitely non trivial. |
Collaborator
|
I'm just wondering if we should cut a 4.0.0 off where we are on main plus the TCP changes when they land and have these refactorings land onto 4.1.0 (4.0.0dev)? We're currently holding up a feature (raw audio) that benefits all users for work that has infrastructure value. It's definitely good to have them, though. |
Member
It's stalled for a good reason though. Now we know it works (but probably would benefit from PLC) but at the start we didn't. |
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.
Short description of changes
This picks up and finishes #3372 (@ann0see's extract of @pgScorpio's work in #2550), which had stalled on review discussion. It contains two commits:
The original Refactor Connect and Disconnect functionality out to CClient #3372 refactor, ported onto current
main(authorship preserved):Connect()/Disconnect()move out ofCClientDlgintoCClient, which emits signals the dialog consumes.CClientDlgno longer holds connection logic — it only reacts (OnConnecting,OnConnectingFailed,OnDisconnect). Connect-on-startup moves out of the dialog constructor intomain.cppviaClient.Connect(...), so it now also works identically in--noguimode.An explicit connection state machine, addressing the state-model review comments in Refactor Connect and Disconnect functionality out to CClient #3372: a new
EConnectionState(CS_DISCONNECTED/CS_CONNECTING/CS_CONNECTED) owned byCClientas the single source of truth, with every transition emittingConnectionStateChanged. Following that discussion's definitions: a connection is requested (CS_CONNECTING) when the audio stream starts toward the configured server, and established (CS_CONNECTED) once the server assigns our channel ID. Accordingly, the signal formerly emitted fromStart()asConnected(name)is renamedConnecting(name), since at that point the connection is only requested.CClient::Connect()now terminates any current connection first, so connecting while connected behaves as a clean reconnect.This is a step toward #3801 (CClient as the orchestration layer behind UI and JSON-RPC): a follow-up PR stacked on this one exposes connect/disconnect/state over JSON-RPC as symmetric consumers of the same signals.
Context: Fixes an issue?
Fixes #3367. Supersedes #3372 (both commits build on it; the first preserves its authorship).
Does this change need documentation? What needs to be documented and how?
No user-facing behavior change. The follow-up JSON-RPC PR updates
docs/JSON-RPC.md.Status of this Pull Request
Ready for review.
What is missing until this pull request can be merged?
Review.
Tested: full GUI build and
CONFIG+=headlessbuild on Linux/Qt 5.15; a--noguiclient was driven through connect → reconnect-while-connected → disconnect cycles against a local server, observing theConnecting/ConnectionStateChanged/Disconnectedsignal sequence via the follow-up PR's JSON-RPC notifications (16/16 scripted checks pass); clean SIGTERM shutdown verified.Checklist
AUTOBUILD: Please build all targets
🤖 Generated with Claude Code