import { useEffect, useState } from 'react'; import { useFiltering } from '../../hooks/useFiltering'; function isRequestedValue(item, renderOptions) { if ( (item.name == "pluviometer" && renderOptions.citzen.pluviometer) || (item.name == "automaticPluviometer" && renderOptions.oficial.automaticPluviometer) || (item.name == "rain" && renderOptions.citzen.rain) || (item.name == "riverFlood" && renderOptions.citzen.riverFlood ) || (item.name == "floodZones" && renderOptions.citzen.floodRisk) || (item.name == "susceptibilityAreas" && renderOptions.oficial.susceptibilityAreas) ) { return true; } } function verify_existingSockets(formType, renderOptions) { if (formType.response == null && isRequestedValue(formType, renderOptions)) { console.log("Criou socket: "+formType.name); const socket = new WebSocket("wss://waterproofing.geog.uni-heidelberg.de/wss/hot/data?" + formType.endpoint); socket.onmessage = ({ data }) => { formType.response = data; } } /* else { console.log("\nresposta preenchida"); }*/ } export default function SocketClient(dataOptionObject, focusChanged, data) { // useEffect(() => { data.map((e) => verify_existingSockets(e, dataOptionObject)); // }, []); console.log("data socket client: "+ JSON.stringify(data)); return data; };