spread out reconnects between 2 and 5 min

This commit is contained in:
Kyle Spearrin 2018-08-31 23:24:43 -04:00
parent 852b4571b3
commit 26625a58d0
1 changed files with 7 additions and 1 deletions

View File

@ -179,7 +179,7 @@ export class NotificationsService implements NotificationsServiceAbstraction {
} catch { }
if (!this.connected) {
this.reconnectTimer = setTimeout(() => this.reconnect(sync), 120000);
this.reconnectTimer = setTimeout(() => this.reconnect(sync), this.random(120000, 300000));
}
}
@ -189,4 +189,10 @@ export class NotificationsService implements NotificationsServiceAbstraction {
}
return false;
}
private random(min: number, max: number) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
}