|
|
@ -165,15 +165,19 @@ function getFormsAnswers(socketObject, dispatch) { |
|
|
|
const [timerCounter, setTimer] = useState(1); |
|
|
|
|
|
|
|
const openListeners = () => { |
|
|
|
// console.log(`rodando forms answ ${socketObject.name}`);
|
|
|
|
socketObject.socketUrl.onerror = (e) => { |
|
|
|
console.log(e.message); |
|
|
|
}; |
|
|
|
|
|
|
|
socketObject.socketUrl.onmessage = ({ data }) => { |
|
|
|
console.log(`\t ====== Recebendo dados: ${socketObject.name} => ${moment().format('DD/MM, h:mm:ss:SSS')}`); |
|
|
|
console.log(`\t ====== Getting data from: ${socketObject.name} => ${moment().format('DD/MM, h:mm:ss:SSS')}`); |
|
|
|
setSocketResponse(data); |
|
|
|
}; |
|
|
|
|
|
|
|
socketObject.socketUrl.onclose = () => { |
|
|
|
console.log(`\t ====== Socket closed : ${socketObject.name} => ${moment().format('DD/MM, h:mm:ss:SSS')}`); |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
openListeners(); |
|
|
@ -181,7 +185,7 @@ function getFormsAnswers(socketObject, dispatch) { |
|
|
|
// Actually closing/opening sockets every 10min
|
|
|
|
useEffect(() => { |
|
|
|
if (timerCounter % 10 == 0) { |
|
|
|
console.log(`========> Deletando e criando sockets: ${socketObject.name} => ${moment().format('DD/MM, h:mm:ss:SSS')}`); |
|
|
|
console.log(`========> Closing/Opening socket: ${socketObject.name} => ${moment().format('DD/MM, h:mm:ss:SSS')}`); |
|
|
|
socketObject.socketUrl.close(); |
|
|
|
socketObject.socketUrl = new WebSocket(socketObject.url); |
|
|
|
openListeners(); |
|
|
|