Skip to content

Commit aec4624

Browse files
AndrewFerrJohennes
authored andcommitted
When state says you've left ongoing call, rejoin (matrix-org#4342)
* When state says you've left ongoing call, rejoin When receiving a state change that says you are no longer a member of a RTC session that you are actually still participating in, send another state event to put yourself back in the session membership. This can happen when an administrator overwrites your call membership event (which is allowed even with MSC3757's restrictions on state), or if your delayed disconnection event (via MSC4140) timed out before your client could send a heartbeat to delay it further. * Don't emit state changed on join recovery
1 parent c1f53a7 commit aec4624

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/matrixrtc/MatrixRTCSession.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,12 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
772772
if (changed) {
773773
logger.info(`Memberships for call in room ${this.room.roomId} have changed: emitting`);
774774
this.emit(MatrixRTCSessionEvent.MembershipsChanged, oldMemberships, this.memberships);
775+
776+
if (this.isJoined() && !this.memberships.some(this.isMyMembership)) {
777+
logger.warn("Missing own membership: force re-join");
778+
// TODO: Should this be awaited? And is there anything to tell the focus?
779+
this.triggerCallMembershipEventUpdate();
780+
}
775781
}
776782

777783
if (this.manageMediaKeys && this.isJoined() && this.makeNewKeyTimeout === undefined) {
@@ -942,6 +948,7 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
942948
}
943949

944950
private triggerCallMembershipEventUpdate = async (): Promise<void> => {
951+
// TODO: Should this await on a shared promise?
945952
if (this.updateCallMembershipRunning) {
946953
this.needCallMembershipUpdate = true;
947954
return;
@@ -1030,7 +1037,6 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
10301037
const stateKey = this.makeMembershipStateKey(localUserId, localDeviceId);
10311038
const prepareDelayedDisconnection = async (): Promise<void> => {
10321039
try {
1033-
// TODO: If delayed event times out, re-join!
10341040
const res = await resendIfRateLimited(() =>
10351041
this.client._unstable_sendDelayedStateEvent(
10361042
this.room.roomId,

0 commit comments

Comments
 (0)