Skip to content

Commit

Permalink
Merge branch 'feat/sendlocation-ws-reconnect' into 'master'
Browse files Browse the repository at this point in the history
feat: Adds send location on WS reconnection.

See merge request prey/js/prey-node-client!1032
  • Loading branch information
Claudio committed Aug 6, 2024
2 parents e27e89c + a20ba6a commit 4946e61
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/agent/control-panel/websockets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) => {
Expand All @@ -356,6 +363,7 @@ exports.startWebsocket = () => {
}
restartWebsocketCall();
}
if (timerSendLocation) clearTimeout(timerSendLocation);
});

ws.on('message', (data) => {
Expand Down

0 comments on commit 4946e61

Please sign in to comment.