Skip to content
Merged
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
13 changes: 9 additions & 4 deletions src/webrtc/groupCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);

Expand Down