add continuous checking
This commit is contained in:
@@ -77,6 +77,8 @@
|
|||||||
<script>
|
<script>
|
||||||
var ws;
|
var ws;
|
||||||
var checked_for_connection = false;
|
var checked_for_connection = false;
|
||||||
|
var connected_to_api = false;
|
||||||
|
setInterval(check_ws_connection, 1000, ws);
|
||||||
assign_button_callbacks();
|
assign_button_callbacks();
|
||||||
openSocket = () => {
|
openSocket = () => {
|
||||||
|
|
||||||
@@ -317,7 +319,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function check_ws_connection(ws) {
|
function check_ws_connection(ws) {
|
||||||
if (checked_for_connection == false)
|
if (checked_for_connection == false && connected_to_api)
|
||||||
{
|
{
|
||||||
console.log("Checking connection to API")
|
console.log("Checking connection to API")
|
||||||
if (ws.readyState != WebSocket.OPEN) {
|
if (ws.readyState != WebSocket.OPEN) {
|
||||||
@@ -337,7 +339,7 @@
|
|||||||
console.log("connected with websockets to API!");
|
console.log("connected with websockets to API!");
|
||||||
document.getElementById("connectedlabel").innerHTML = "Connected to drone";
|
document.getElementById("connectedlabel").innerHTML = "Connected to drone";
|
||||||
document.getElementById("connectbutton").disabled = true;
|
document.getElementById("connectbutton").disabled = true;
|
||||||
setInterval(check_ws_connection, 1000, ws);
|
connected_to_api = true;
|
||||||
openSocket();
|
openSocket();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user