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