forked from mystiq/hydrogen-web
ensure there is no race between reconnecting & updating the session id
it's probably fine as connect has to wait to receive the negotiationneeded event before it can send out an invite, but just to be sure update the session id beforehand
This commit is contained in:
parent
aa709ee6e9
commit
a91bcf5d22
1 changed files with 10 additions and 6 deletions
|
@ -131,24 +131,28 @@ export class Member {
|
||||||
updateCallInfo(callDeviceMembership: CallDeviceMembership, log: ILogItem) {
|
updateCallInfo(callDeviceMembership: CallDeviceMembership, log: ILogItem) {
|
||||||
log.wrap({l: "updateing device membership", deviceId: this.deviceId}, log => {
|
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
|
// session id is changing, disconnect so we start with a new slate for the new session
|
||||||
if (callDeviceMembership.session_id !== this.sessionId) {
|
const oldSessionId = this.sessionId;
|
||||||
|
this.callDeviceMembership = callDeviceMembership;
|
||||||
|
if (oldSessionId !== this.sessionId) {
|
||||||
log.wrap({
|
log.wrap({
|
||||||
l: "member event changes session id",
|
l: "member event changes session id",
|
||||||
oldSessionId: this.sessionId,
|
oldSessionId,
|
||||||
newSessionId: callDeviceMembership.session_id
|
newSessionId: this.sessionId
|
||||||
}, log => {
|
}, log => {
|
||||||
// prevent localMedia from being stopped
|
// prevent localMedia from being stopped
|
||||||
// as connect won't be called again when reconnecting
|
// as connect won't be called again when reconnecting
|
||||||
// to the new session
|
// to the new session
|
||||||
const localMedia = this.localMedia;
|
const localMedia = this.localMedia!;
|
||||||
this.localMedia = undefined;
|
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);
|
this.disconnect(false);
|
||||||
// connect again, as the other side might be waiting for our invite
|
// connect again, as the other side might be waiting for our invite
|
||||||
// after refreshing
|
// after refreshing
|
||||||
this.connect(localMedia!, this.localMuteSettings!);
|
this.connect(localMedia, this.localMuteSettings!);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.callDeviceMembership = callDeviceMembership;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue