Free olmSas after all stages have completed

This commit is contained in:
RMidhunSuresh 2023-02-22 13:00:36 +05:30
parent 3321859ae6
commit 5e1dca946b
No known key found for this signature in database

View File

@ -26,9 +26,11 @@ type Olm = typeof OlmNamespace;
export class SASVerification { export class SASVerification {
private startStage: BaseSASVerificationStage; private startStage: BaseSASVerificationStage;
private olmSas: Olm.SAS;
constructor(private room: Room, private olm: Olm, private olmUtil: Olm.Utility, private ourUser: UserData, otherUserId: string, log: ILogItem) { constructor(private room: Room, private olm: Olm, private olmUtil: Olm.Utility, private ourUser: UserData, otherUserId: string, log: ILogItem) {
const olmSas = new olm.SAS(); const olmSas = new olm.SAS();
this.olmSas = olmSas;
try { try {
const options = { room, ourUser, otherUserId, log, olmSas, olmUtil }; const options = { room, ourUser, otherUserId, log, olmSas, olmUtil };
let stage: BaseSASVerificationStage = new StartVerificationStage(options); let stage: BaseSASVerificationStage = new StartVerificationStage(options);
@ -51,15 +53,19 @@ export class SASVerification {
console.log("startStage", this.startStage); console.log("startStage", this.startStage);
} }
finally { finally {
olmSas.free();
} }
} }
async start() { async start() {
try {
let stage = this.startStage; let stage = this.startStage;
do { do {
await stage.completeStage(); await stage.completeStage();
stage = stage.nextStage; stage = stage.nextStage;
} while (stage); } while (stage);
} }
finally {
this.olmSas.free();
}
}
} }