1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00

split between initial connection timer and reconnection timers

This commit is contained in:
Massimo Candela
2021-06-14 18:56:29 +02:00
parent 39c06a64a1
commit 126531ca8b
2 changed files with 7 additions and 3 deletions

View File

@@ -50,6 +50,7 @@ export default class ConnectorSwUpdates extends Connector{
url: "https://raw.githubusercontent.com/nttgin/BGPalerter/main/package.json"
})
.then(data => {
if (data && data.data && data.data.version && semver.gt(data.data.version, this.version)) {
this._message({
type: "software-update",

View File

@@ -9,8 +9,9 @@ export default class WebSocket {
this.options = options;
this.ws = null;
this.alive = false;
this.pingInterval = options.pingInterval || 40000;
this.reconnectSeconds = options.reconnectSeconds || 30000;
this.pingInterval = options.pingIntervalSeconds ? options.pingIntervalSeconds * 1000 : 40000;
this.reconnectSeconds = options.reconnectSeconds ? options.reconnectSeconds * 1000 : 30000;
this.connectionDelay = 5000;
this.lastPingReceived = null;
}
@@ -85,7 +86,9 @@ export default class WebSocket {
if (this.connectTimeout) {
clearTimeout(this.connectTimeout);
}
this.connectTimeout = setTimeout(this._connect, this.reconnectSeconds);
this.connectTimeout = setTimeout(this._connect, this.connectionDelay);
this.connectionDelay = this.reconnectSeconds;
};
disconnect = () => {