websocket auto reconnect
This commit is contained in:
parent
3547f0e377
commit
ecd0b8ecf5
@ -108,9 +108,7 @@ func (t *TrackingService) StartLivetracking(cols ...CollectorType) (string, erro
|
|||||||
return "RECORDING", errors.New(txt)
|
return "RECORDING", errors.New(txt)
|
||||||
}
|
}
|
||||||
if t.opMode == REPLAY {
|
if t.opMode == REPLAY {
|
||||||
txt := "trackingservice: please stop Replay before resetting pipeline"
|
t.StopAll()
|
||||||
logrus.Warn(txt)
|
|
||||||
return "RECORDING", errors.New(txt)
|
|
||||||
}
|
}
|
||||||
if t.opMode == LIVE {
|
if t.opMode == LIVE {
|
||||||
txt := "trackingservice: stop tracking running stream before creating new one"
|
txt := "trackingservice: stop tracking running stream before creating new one"
|
||||||
|
|||||||
@ -1,19 +1,34 @@
|
|||||||
const GRAPH_RES = 100;
|
const GRAPH_RES = 100;
|
||||||
var dataSmartphone = [];
|
var dataSmartphone = [];
|
||||||
|
var ws;
|
||||||
|
|
||||||
|
|
||||||
window.addEventListener("load", function(evt) {
|
window.addEventListener("load", function(evt) {
|
||||||
var output = document.getElementById("output");
|
var output = document.getElementById("output");
|
||||||
var checkBoxSmartphone = document.getElementById("checkbox1");
|
var checkBoxSmartphone = document.getElementById("checkbox1");
|
||||||
var checkBoxUblox = document.getElementById("checkbox2");
|
var checkBoxUblox = document.getElementById("checkbox2");
|
||||||
var ws;
|
|
||||||
ws = new WebSocket("ws://localhost:3011/ws");
|
const wsOnCloseF = function (evt) {
|
||||||
ws.onopen = function(evt) {
|
|
||||||
print("OPEN");
|
|
||||||
}
|
|
||||||
ws.onclose = function(evt) {
|
|
||||||
ws = null;
|
ws = null;
|
||||||
print2("CLOSE");
|
print2("CLOSE");
|
||||||
|
var intervalId;
|
||||||
|
intervalId = setInterval(() => {
|
||||||
|
console.log("reconnect websocket...")
|
||||||
|
if (ws !== null && ws.CONNECTING) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (ws !== null && ws.OPEN) {
|
||||||
|
clearInterval(intervalId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ws = new WebSocket("ws://localhost:3011/ws");
|
||||||
|
ws.onopen = wsOnOpenF
|
||||||
|
ws.onclose = wsOnCloseF
|
||||||
|
ws.onmessage = wsOnMessageF
|
||||||
|
ws.onerror = wsOnErrorF
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
ws.onmessage = function(evt) {
|
const wsOnMessageF = function (evt) {
|
||||||
//print2("RESPONSE: " + evt.data);
|
//print2("RESPONSE: " + evt.data);
|
||||||
// let dat = JSON.parse(evt.data)["bmi26x gyroscope"]
|
// let dat = JSON.parse(evt.data)["bmi26x gyroscope"]
|
||||||
// let dat = JSON.parse(evt.data)["lsm6dsm gyroscope"]
|
// let dat = JSON.parse(evt.data)["lsm6dsm gyroscope"]
|
||||||
@ -109,10 +124,20 @@ window.addEventListener("load", function(evt) {
|
|||||||
console.log("no TCP acc")
|
console.log("no TCP acc")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const wsOnOpenF = function (evt) {
|
||||||
ws.onerror = function(evt) {
|
print2("OPEN");
|
||||||
print("ERROR: " + evt.data);
|
|
||||||
}
|
}
|
||||||
|
const wsOnErrorF = function(evt) {
|
||||||
|
console.log(evt)
|
||||||
|
print2("ERROR: " + evt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ws = new WebSocket("ws://localhost:3011/ws");
|
||||||
|
ws.onopen = wsOnOpenF
|
||||||
|
ws.onclose = wsOnCloseF
|
||||||
|
ws.onmessage = wsOnMessageF
|
||||||
|
ws.onerror = wsOnErrorF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -198,7 +223,7 @@ window.addEventListener("load", function(evt) {
|
|||||||
.then(console.log);
|
.then(console.log);
|
||||||
checkBoxSmartphone.disabled = false;
|
checkBoxSmartphone.disabled = false;
|
||||||
checkBoxUblox.disabled = false;
|
checkBoxUblox.disabled = false;
|
||||||
document.getElementById("tracking state").innerHTML = "Tracking state: PIPELINE CLOSED"
|
document.getElementById("tracking state").innerHTML = "Tracking state: CLOSED"
|
||||||
//ws.close();
|
//ws.close();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
<label id="diffLat" style= "font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif">Differenz lat: </label>
|
<label id="diffLat" style= "font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif">Differenz lat: </label>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="100%">
|
<td valign="top" width="100%">
|
||||||
<div id="output"></div>
|
<div id="output"><p>.</p></div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user