From a20ba6a206187df68b78a568527fd04bc1877400 Mon Sep 17 00:00:00 2001 From: Antoniojose Figueroa Date: Tue, 6 Aug 2024 11:06:44 -0400 Subject: [PATCH] feat: Adds send location on WS reconnection. --- lib/agent/control-panel/websockets/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/agent/control-panel/websockets/index.js b/lib/agent/control-panel/websockets/index.js index 7c3a829eb..033915321 100644 --- a/lib/agent/control-panel/websockets/index.js +++ b/lib/agent/control-panel/websockets/index.js @@ -40,6 +40,7 @@ let websocketConnected = false; let workingWithProxy = true; let countNotConnectionProxy = 0; let pongReceived = false; +let timerSendLocation; const startupTimeout = 5000; const heartbeatTimeout = 120000 + 1000; @@ -346,6 +347,12 @@ exports.startWebsocket = () => { }); } }); + if (timerSendLocation) clearTimeout(timerSendLocation); + timerSendLocation = setTimeout(() => { + hooks.trigger('get_location', 'interval'); + logger.info('Sending location interval'); + }, 1000 * 10); + }); ws.on('close', (code) => { @@ -356,6 +363,7 @@ exports.startWebsocket = () => { } restartWebsocketCall(); } + if (timerSendLocation) clearTimeout(timerSendLocation); }); ws.on('message', (data) => {