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 {
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) {
const olmSas = new olm.SAS();
this.olmSas = olmSas;
try {
const options = { room, ourUser, otherUserId, log, olmSas, olmUtil };
let stage: BaseSASVerificationStage = new StartVerificationStage(options);
@ -51,15 +53,19 @@ export class SASVerification {
console.log("startStage", this.startStage);
}
finally {
olmSas.free();
}
}
async start() {
let stage = this.startStage;
do {
await stage.completeStage();
stage = stage.nextStage;
} while (stage);
try {
let stage = this.startStage;
do {
await stage.completeStage();
stage = stage.nextStage;
} while (stage);
}
finally {
this.olmSas.free();
}
}
}