Start processing member state events only after we've set out own (#2000)

This avoids a race condition where the other side would first receive the to-device messages and only then the member state event which would result in the call being ignored

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2021-10-25 23:02:28 +02:00
committed by GitHub
parent b4d8c0b603
commit fc8a867e8e
+9 -4
View File
@@ -239,7 +239,7 @@ export class GroupCall extends EventEmitter {
this.addParticipant(this.room.getMember(this.client.getUserId()));
this.sendMemberStateEvent();
const sendMemberStateEventPromise = this.sendMemberStateEvent();
this.activeSpeaker = null;
@@ -262,9 +262,14 @@ export class GroupCall extends EventEmitter {
logger.log("Processing initial members");
for (const stateEvent of memberStateEvents) {
this.onMemberStateChanged(stateEvent);
}
// This avoids a race condition where the other side would first receive
// the to-device messages and only then the member state event which
// would result in the call being ignored
sendMemberStateEventPromise.then(() => {
for (const stateEvent of memberStateEvents) {
this.onMemberStateChanged(stateEvent);
}
});
this.client.on("Call.incoming", this.onIncomingCall);