|
|
@ -2,6 +2,7 @@ import { useState, useEffect, useReducer, useContext } from "react"; |
|
|
|
import assets from "../config/assets"; |
|
|
|
import PinIntransitavel from "../assets/floodZonesAssets/PinIntransitavel"; |
|
|
|
import PinTransitavel from "../assets/floodZonesAssets/PinTransitavel"; |
|
|
|
import moment from "moment"; |
|
|
|
|
|
|
|
const custom_assets = { |
|
|
|
pluviometer: assets.pluviometer, |
|
|
@ -170,6 +171,7 @@ function getFormsAnswers(socketObject, dispatch) { |
|
|
|
}; |
|
|
|
|
|
|
|
socketObject.socketUrl.onmessage = ({ data }) => { |
|
|
|
console.log(`\t ====== Recebendo dados: ${socketObject.name} => ${moment().format('DD/MM, h:mm:ss:SSS')}`); |
|
|
|
setSocketResponse(data); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -179,7 +181,7 @@ function getFormsAnswers(socketObject, dispatch) { |
|
|
|
// Actually closing/opening sockets every 10min
|
|
|
|
useEffect(() => { |
|
|
|
if (timerCounter % 10 == 0) { |
|
|
|
console.log("===== Runing interval " + socketObject.name + " ========" + timerCounter); |
|
|
|
console.log(`========> Deletando e criando sockets: ${socketObject.name} => ${moment().format('DD/MM, h:mm:ss:SSS')}`); |
|
|
|
socketObject.socketUrl.close(); |
|
|
|
socketObject.socketUrl = new WebSocket(socketObject.url); |
|
|
|
openListeners(); |
|
|
|