Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ee/packages/media-calls/src/internal/SignalProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ export class GlobalSignalProcessor {
const role = isCaller ? 'caller' : 'callee';
const callActor = call[role];

// Hangup requests from different clients won't be coming from the signed client
const skipContractCheck = signal.type === 'hangup' && signal.reason === 'another-client';

// Ignore signals from different sessions if the actor is already signed
if (callActor.contractId && callActor.contractId !== signal.contractId) {
if (!skipContractCheck && callActor.contractId && callActor.contractId !== signal.contractId) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class UserActorSignalProcessor {
// 1. the signal came from the exact user session where the caller initiated the call
// 2. the signal came from the exact user session where the callee accepted the call
// 3. the call has not been accepted yet and the signal came from a valid session from the callee
// 4. It's a hangup request with reason = 'another-client' and the request came from any valid client of either user
switch (signal.type) {
case 'local-sdp':
return this.saveLocalDescription(signal.sdp, signal.negotiationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type CallState =
| 'renegotiating' // a webrtc connection had been established before, but a new one is being negotiated
| 'hangup'; // call is over

// Changes to this list must be reflected on the enum for clientMediaSignalHangupSchema too
export type CallHangupReason =
| 'normal' // User explicitly hanged up
| 'remote' // The client was told the call is over
Expand All @@ -38,7 +39,8 @@ export type CallHangupReason =
| 'media-error' // Hanging up because of an error setting up the media connection
| 'input-error' // Something wrong with the audio input track on the client
| 'error' // Hanging up because of an unidentified error
| 'unknown'; // One of the call's signed users reported they don't know this call
| 'unknown' // One of the call's signed users reported they don't know this call
| 'another-client'; // One of the call's users requested a hangup from a different client session than the one where the call is happening

export type CallAnswer =
| 'accept' // actor accepts the call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export const clientMediaSignalHangupSchema: JSONSchemaType<ClientMediaSignalHang
'signaling-error',
'service-error',
'media-error',
'input-error',
'error',
'unknown',
'another-client',
],
nullable: false,
},
Expand Down
6 changes: 6 additions & 0 deletions packages/media-signaling/src/lib/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ export class ClientMediaCall implements IClientMediaCall {
return;
}

// If the hangup was requested by the user but the call is not happening here, send an 'another-client' hangup request to the server and wait for the server to hangup the call
if (reason === 'normal' && this.contractState === 'ignored') {
this.config.transporter.hangup(this.callId, 'another-client');
return;
}

if (this.hidden) {
return;
}
Expand Down
Loading