Switch from socket.io to REST for cadence streaming in attempt to fix timeout issue
This commit is contained in:
@@ -24,6 +24,7 @@ async function connect(props) {
|
||||
console.log("> Notifications started");
|
||||
characteristic.addEventListener("characteristicvaluechanged", props.onChange);
|
||||
console.log("> Characteristic value changed event listener added");
|
||||
/*
|
||||
socket = io({
|
||||
reconnection: true,
|
||||
reconnectionDelay: 1000,
|
||||
@@ -43,6 +44,7 @@ async function connect(props) {
|
||||
}
|
||||
// else the socket will automatically try to reconnect
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
async function disconnect() {
|
||||
@@ -88,7 +90,15 @@ function parseCSC(e) {
|
||||
if (prevRes) {
|
||||
let rpm = revsToRPM(prevRes, res);
|
||||
if (rpm > 0)
|
||||
socket.emit("message", { rpm: parseFloat(rpm.toFixed(2)), id: 1 });
|
||||
//socket.emit("message", { rpm: parseFloat(rpm.toFixed(2)), id: 1 });
|
||||
fetch("/cadence", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json, text/plain, */*",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ rpm: parseFloat(rpm.toFixed(2)), id: 1 }),
|
||||
});
|
||||
}
|
||||
prevRes = res;
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user