-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(plugin-meetings): moderated unmute when client is remotely muted #3995
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ export class MuteState { | |
}; | ||
server: {localMute: boolean; remoteMute: boolean; unmuteAllowed: boolean}; | ||
syncToServerInProgress: boolean; | ||
isRemoteUnmutePendingLocusDtoUpdate: boolean; // true if we've sent a remote unmute request to Locus and haven't received a Locus DTO confirming it happened, yet | ||
}; | ||
|
||
type: any; | ||
|
@@ -62,6 +63,7 @@ export class MuteState { | |
unmuteAllowed: type === AUDIO ? meeting.unmuteAllowed : meeting.unmuteVideoAllowed ?? true, | ||
}, | ||
syncToServerInProgress: false, | ||
isRemoteUnmutePendingLocusDtoUpdate: false, | ||
}; | ||
} | ||
|
||
|
@@ -327,6 +329,13 @@ export class MuteState { | |
`Meeting:muteState#sendRemoteMuteRequestToServer --> ${this.type}: sending remote mute:${remoteMute} to server` | ||
); | ||
|
||
this.state.isRemoteUnmutePendingLocusDtoUpdate = true; | ||
|
||
setTimeout(() => { | ||
console.log('marcin: resetting isRemoteUnmutePendingLocusDtoUpdate after timeout'); | ||
this.state.isRemoteUnmutePendingLocusDtoUpdate = false; | ||
}, 10 * 1000); | ||
|
||
return meeting.members | ||
.muteMember(meeting.members.selfId, remoteMute, this.type === AUDIO) | ||
.then(() => { | ||
|
@@ -337,6 +346,8 @@ export class MuteState { | |
this.state.server.remoteMute = remoteMute; | ||
}) | ||
.catch((remoteUpdateError) => { | ||
this.state.isRemoteUnmutePendingLocusDtoUpdate = false; | ||
|
||
LoggerProxy.logger.warn( | ||
`Meeting:muteState#sendRemoteMuteRequestToServer --> ${this.type}: failed to apply remote mute ${remoteMute} to server: ${remoteUpdateError}` | ||
); | ||
|
@@ -359,6 +370,23 @@ export class MuteState { | |
} | ||
} | ||
|
||
public shouldIgnoreRemoteMuteUpdate(remoteMute: boolean, isModifiedBySelf: boolean) { | ||
console.log( | ||
`marcin: shouldIgnoreRemoteMuteUpdate: flag=${this.state.isRemoteUnmutePendingLocusDtoUpdate} remoteMute=${remoteMute}, isModifiedBySelf=${isModifiedBySelf}` | ||
); | ||
if (this.state.isRemoteUnmutePendingLocusDtoUpdate && isModifiedBySelf && !remoteMute) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only ever send remote unmute requests (not mute), so here I'm only checking for |
||
console.log('marcin: FIX: ignoring remote mute update'); | ||
|
||
this.state.isRemoteUnmutePendingLocusDtoUpdate = false; | ||
|
||
return true; | ||
} | ||
|
||
console.log('marcin: FIX: NOT ignoring remote mute update'); | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* This method should be called whenever the server remote mute state is changed | ||
* | ||
|
@@ -379,12 +407,7 @@ export class MuteState { | |
} | ||
if (muted !== undefined) { | ||
this.state.server.remoteMute = muted; | ||
|
||
// We never want to unmute the local stream from a server remote mute update. | ||
// Moderated unmute is handled by a different function. | ||
if (muted) { | ||
this.muteLocalStream(meeting, muted, 'remotelyMuted'); | ||
} | ||
this.muteLocalStream(meeting, muted, 'remotelyMuted'); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't do the full check if we should ignore or not here, because selfUtils.ts doesn't have a reference to the meeting or MuteState class, so I've added the field
isModifiedBySelf
that's emitted with theSELF_REMOTE_MUTE_STATUS_UPDATED
event and I've put all the logic to decide if we ignore the Locus DTO update or not inMuteState.shouldIgnoreRemoteMuteUpdate()