fix(protocol): deliver self-initiated state changes to the actor too
A connected Windows client would randomly snap from its joined channel back to Lobby. Root cause was a state-sync inconsistency, not a drop: the server delivered self-initiated state changes (channel join/leave, stream announce/stop) only as a private *Result to the actor and broadcast the authoritative UserEvent::UPDATED to everyone else. The core never applied the result to its SessionModel, so vc_list_users() kept self in the old channel; the Windows HandleUserUpdated rebuilds _currentChannelId from vc_list_users() on any user's UPDATED event, so the next unrelated event surfaced the stale self-channel. Fix, per the response-vs-broadcast contract now documented in docs/protocol.md §6: the *Result is pure ack/correlation/actor-private payload; the resulting state change is broadcast to every client INCLUDING the actor, and clients apply it to their local model rather than re-deriving own state from a *Result. - server: join/leave/stream announce+stop broadcast with exclude=0 - server: text fan-out includes the sender (channel + private echo) - core: response handlers no longer mutate session_model_ - windows: drop optimistic text echo; render own message via the relay - docs/protocol.md §6: document the response-vs-broadcast contract Registry-level admin broadcasts (move/mute/kick/channel CRUD) already used exclude=0 and were correct. ctest build/m1-dev 18/18 green; VoiceCat.App builds 0 warnings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -532,6 +532,9 @@ void vc_client::handle_channel_event(const voicecat::v1::ChannelEvent& ce) {
|
||||
}
|
||||
|
||||
void vc_client::handle_join_channel_result(const voicecat::v1::JoinChannelResult& msg) {
|
||||
// This response only acks the request + carries our private audio config. The
|
||||
// authoritative channel change reaches us as a UserEvent::UPDATED broadcast (the server
|
||||
// no longer excludes the mover), which keeps session_model_ in sync via apply_user_event.
|
||||
vc_event ev{};
|
||||
ev.type = VC_EVENT_JOIN_RESULT;
|
||||
ev.result = msg.ok() ? VC_OK : VC_ERR_PROTOCOL;
|
||||
|
||||
Reference in New Issue
Block a user