add & remove rather than update when session id changed

This commit is contained in:
Bruno Windels 2022-04-28 16:52:42 +01:00
parent 3d83fda69f
commit d346f4a3fb
2 changed files with 9 additions and 24 deletions

View file

@ -233,10 +233,17 @@ export class GroupCall extends EventEmitter<{change: never}> {
}
} else {
let member = this._members.get(memberKey);
if (member) {
const sessionIdChanged = member && member.sessionId !== device.session_id;
if (member && !sessionIdChanged) {
log.set("update", true);
member!.updateCallInfo(device, log);
member.updateCallInfo(device, log);
} else {
if (member && sessionIdChanged) {
log.set("removedSessionId", member.sessionId);
member.disconnect(false);
this._members.remove(memberKey);
member = undefined;
}
const logItem = this.logItem.child({l: "member", id: memberKey});
log.set("add", true);
log.refDetached(logItem);

View file

@ -132,29 +132,7 @@ export class Member {
/** @internal */
updateCallInfo(callDeviceMembership: CallDeviceMembership, log: ILogItem) {
log.wrap({l: "updateing device membership", deviceId: this.deviceId}, log => {
// session id is changing, disconnect so we start with a new slate for the new session
const oldSessionId = this.sessionId;
this.callDeviceMembership = callDeviceMembership;
if (oldSessionId !== this.sessionId) {
log.wrap({
l: "member event changes session id",
oldSessionId,
newSessionId: this.sessionId
}, log => {
// prevent localMedia from being stopped
// as connect won't be called again when reconnecting
// to the new session
const localMedia = this.localMedia!;
this.localMedia = undefined;
// don't send a hangup event, as the old session id client is offline already
// and we'd send it with the wrong session id anyway as callDeviceMembership
// has already been replaced.
this.disconnect(false);
// connect again, as the other side might be waiting for our invite
// after refreshing
this.connect(localMedia, this.localMuteSettings!);
});
}
});
}