add continuous checking

This commit is contained in:
Sem van der Hoeven
2023-06-08 12:15:48 +02:00
parent b22d8228aa
commit f50e2d0d57

View File

@@ -77,6 +77,8 @@
<script>
var ws;
var checked_for_connection = false;
var connected_to_api = false;
setInterval(check_ws_connection, 1000, ws);
assign_button_callbacks();
openSocket = () => {
@@ -317,7 +319,7 @@
}
function check_ws_connection(ws) {
if (checked_for_connection == false)
if (checked_for_connection == false && connected_to_api)
{
console.log("Checking connection to API")
if (ws.readyState != WebSocket.OPEN) {
@@ -337,7 +339,7 @@
console.log("connected with websockets to API!");
document.getElementById("connectedlabel").innerHTML = "Connected to drone";
document.getElementById("connectbutton").disabled = true;
setInterval(check_ws_connection, 1000, ws);
connected_to_api = true;
openSocket();
});