Skip to content

Commit

Permalink
Merge pull request #82 from open-voip-alliance/38-stop-health-checker
Browse files Browse the repository at this point in the history
Added function to stop the health checker on disconnect
  • Loading branch information
patrickswijgman authored Dec 31, 2020
2 parents 3c52a15 + a14b854 commit 4c9d96f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ export class ReconnectableTransport extends EventEmitter implements ITransport {

delete this.registeredPromise;

// To avoid sending OPTIONS requests after disconnecting.
this.stopHealthChecker();

// Unregistering is not possible when the socket connection is closed/interrupted
// - by the server during a call
// - by a network node during a call
Expand Down Expand Up @@ -727,12 +730,15 @@ export class ReconnectableTransport extends EventEmitter implements ITransport {
this.dyingIntervalID = window.setInterval(subtractTillDead, subtractValue);
}

private createHealthChecker() {
private stopHealthChecker() {
if (this.healthChecker) {
this.healthChecker.stop();
delete this.healthChecker;
}
}

private createHealthChecker() {
this.stopHealthChecker();
this.healthChecker = new HealthChecker(this.userAgent);
}

Expand Down

0 comments on commit 4c9d96f

Please sign in to comment.