Skip to content

Commit fac4f49

Browse files
committed
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.
1 parent 66c8094 commit fac4f49

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/matrixrtc/MatrixRTCSession.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,14 @@ 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+
// TODO: Is this needed?
781+
this.emit(MatrixRTCSessionEvent.JoinStateChanged, true);
782+
}
775783
}
776784

777785
if (this.manageMediaKeys && this.isJoined() && this.makeNewKeyTimeout === undefined) {
@@ -942,6 +950,7 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
942950
}
943951

944952
private triggerCallMembershipEventUpdate = async (): Promise<void> => {
953+
// TODO: Should this await on a shared promise?
945954
if (this.updateCallMembershipRunning) {
946955
this.needCallMembershipUpdate = true;
947956
return;
@@ -1025,7 +1034,6 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
10251034
);
10261035
} else {
10271036
try {
1028-
// TODO: If delayed event times out, re-join!
10291037
const res = await this.client._unstable_sendDelayedStateEvent(
10301038
this.room.roomId,
10311039
{

0 commit comments

Comments
 (0)