fix: prevent auto-connect on dm_call_accepted for non-caller instances
Three fixes for multi-instance call state consistency: 1. Client dm_call_accepted handler only auto-connects to LiveKit if the user was the caller (outgoingCall was set). Other instances of the same user just clear ringing state without connecting. 2. Server processDmCallAcceptEvent remote path skips duplicate broadcast when FederatedCallEntry is already active (prevents state conflicts from host fan-out arriving after local accept). 3. Ready payload handler clears stuck incomingCall when restoring an already-active call after page refresh.
This commit is contained in:
@@ -3614,12 +3614,18 @@ function processDmCallAcceptEvent(
|
||||
// We're a REMOTE instance receiving fan-out — transition local state
|
||||
const fedCall = connectionManager.getFederatedCall(event.federatedId);
|
||||
if (fedCall) {
|
||||
// Only broadcast if transitioning from ringing → active.
|
||||
// If already active (e.g., we initiated the accept and the host is fanning out back),
|
||||
// skip the duplicate broadcast to avoid state conflicts on the client.
|
||||
const wasRinging = fedCall.state === 'ringing';
|
||||
connectionManager.activateFederatedCall(event.federatedId);
|
||||
connectionManager.sendToFederatedCallUsers(event.federatedId, {
|
||||
type: 'dm_call_accepted',
|
||||
dmChannelId: fedCall.dmChannelId,
|
||||
federatedCallId: event.federatedId,
|
||||
} as ServerEvent);
|
||||
if (wasRinging) {
|
||||
connectionManager.sendToFederatedCallUsers(event.federatedId, {
|
||||
type: 'dm_call_accepted',
|
||||
dmChannelId: fedCall.dmChannelId,
|
||||
federatedCallId: event.federatedId,
|
||||
} as ServerEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user