Skip to content

Commit

Permalink
Update socket timeout connect
Browse files Browse the repository at this point in the history
  • Loading branch information
yumata committed Nov 16, 2023
1 parent d26db65 commit 50f7356
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -15018,10 +15018,17 @@
var _devices = [];
var listener$7 = start$6();
var expects = [];
var timeping = 5000;
var timeout;

function connect$1() {
if (!window.lampa_settings.socket_use) return;
clearInterval(ping);
clearTimeout(timeout);
timeout = setTimeout(function () {
console.log('Socket', 'timeout close');
if (socket) socket.close();
}, 10000);

try {
socket = new WebSocket(window.lampa_settings.socket_url);
Expand All @@ -15032,13 +15039,18 @@
if (!socket) return;
socket.addEventListener('open', function (event) {
console.log('Socket', 'open');
timeping = 5000;
clearTimeout(timeout);
send('start', {});
listener$7.send('open', {});
});
socket.addEventListener('close', function (event) {
console.log('Socket', 'close', event.code);
clearTimeout(timeout);
listener$7.send('close', {});
setTimeout(connect$1, 5000);
console.log('Socket', 'try connect after', Math.round(timeping) / 1000, 'sec.');
setTimeout(connect$1, Math.round(timeping));
timeping *= 2;
});
socket.addEventListener('error', function (event) {
console.log('Socket', 'error:', 'maybe there is no connection to the server');
Expand Down

0 comments on commit 50f7356

Please sign in to comment.