| | |
| | | PageContainer, |
| | | } from '@ant-design/pro-components'; |
| | | import './index.less' |
| | | import { WEBSOCKET_BASE_URL } from '@/config/setting'; |
| | | |
| | | const Main = () => { |
| | | const [deviceInfos, setDeviceInfos] = useState([]); |
| | |
| | | const [mapLev, setMapLev] = useState([]); |
| | | |
| | | useEffect(() => { |
| | | var newWs = new WebSocket("ws://127.0.0.1:9090/wcs/ws/lift/websocket"); |
| | | setWs(newWs); |
| | | connect(); |
| | | |
| | | getMapLev(); |
| | | |
| | |
| | | |
| | | ws.onclose = function (e) { |
| | | console.log("close"); |
| | | reconnect(); |
| | | } |
| | | |
| | | ws.onerror = function (e) { |
| | |
| | | } |
| | | }, [ws]); |
| | | |
| | | const connect = () => { |
| | | var newWs = new WebSocket(WEBSOCKET_BASE_URL + "/ws/lift/websocket"); |
| | | setWs(newWs); |
| | | } |
| | | |
| | | const reconnect = () => { |
| | | setTimeout(() => { |
| | | console.log('WebSocketClient: Attempting to reconnect...'); |
| | | connect(); |
| | | }, 3000); |
| | | } |
| | | |
| | | const sendWs = (message) => { |
| | | if (ws.readyState == WebSocket.OPEN) { |
| | | ws.send(message) |
| | |
| | | PageContainer, |
| | | } from '@ant-design/pro-components'; |
| | | import './index.less' |
| | | import { WEBSOCKET_BASE_URL } from '@/config/setting'; |
| | | |
| | | const Main = () => { |
| | | const [deviceInfos, setDeviceInfos] = useState([]); |
| | |
| | | }, [ws]); |
| | | |
| | | const connect = () => { |
| | | var newWs = new WebSocket("ws://127.0.0.1:9090/wcs/ws/shuttle/websocket"); |
| | | var newWs = new WebSocket(WEBSOCKET_BASE_URL + "/ws/shuttle/websocket"); |
| | | setWs(newWs); |
| | | } |
| | | |