unify dispose logic in Member

This commit is contained in:
Bruno Windels 2022-10-06 15:22:15 +02:00
parent 7eb8015ace
commit 2ecfb8f139

View File

@ -83,6 +83,12 @@ class MemberConnection {
return first.content.seq === this.lastProcessedSeqNr || return first.content.seq === this.lastProcessedSeqNr ||
first.content.seq === this.lastProcessedSeqNr + 1; first.content.seq === this.lastProcessedSeqNr + 1;
} }
dispose() {
this.peerCall?.dispose();
this.localMedia.dispose();
this.logItem.finish();
}
} }
export class Member { export class Member {
@ -210,18 +216,15 @@ export class Member {
return; return;
} }
let disconnectLogItem; let disconnectLogItem;
// if if not sending the hangup, still log disconnect
connection.logItem.wrap("disconnect", async log => { connection.logItem.wrap("disconnect", async log => {
disconnectLogItem = log; disconnectLogItem = log;
if (hangup) { if (hangup && connection.peerCall) {
await connection.peerCall?.hangup(CallErrorCode.UserHangup, log); await connection.peerCall.hangup(CallErrorCode.UserHangup, log);
} else {
await connection.peerCall?.close(undefined, log);
} }
connection.peerCall?.dispose();
connection.localMedia?.dispose();
this.connection = undefined;
}); });
connection.logItem.finish(); connection.dispose();
this.connection = undefined;
return disconnectLogItem; return disconnectLogItem;
} }
@ -395,8 +398,10 @@ export class Member {
} }
dispose() { dispose() {
this.connection?.dispose();
this.connection = undefined;
this.expireTimeout?.dispose(); this.expireTimeout?.dispose();
this.connection?.peerCall?.dispose(); this.expireTimeout = undefined;
} }
} }