| | |
| | | currentLev: 1, |
| | | mapFps: 0, |
| | | ws: null, |
| | | wsReconnectTimer: null, |
| | | wsReconnectAttempts: 0, |
| | | wsReconnectBaseDelay: 1000, |
| | | wsReconnectMaxDelay: 15000, |
| | | pixiApp: null, |
| | | pixiStageList: [], |
| | | pixiStaMap: new Map(), |
| | |
| | | mounted() { |
| | | this.currentLev = this.lev || 1; |
| | | this.createMap(); |
| | | this.ws = new WebSocket("ws://" + window.location.host + baseUrl + "/console/websocket"); |
| | | this.ws.onopen = this.webSocketOnOpen; |
| | | this.ws.onerror = this.webSocketOnError; |
| | | this.ws.onmessage = this.webSocketOnMessage; |
| | | this.ws.onclose = this.webSocketClose; |
| | | this.connectWs(); |
| | | |
| | | setTimeout(() => { |
| | | this.getMap(this.currentLev); |
| | |
| | | if (this.timer) { clearInterval(this.timer); } |
| | | if (this.pixiApp) { this.pixiApp.destroy(true, { children: true }); } |
| | | window.removeEventListener('resize', this.resizeToContainer); |
| | | if (this.wsReconnectTimer) { clearTimeout(this.wsReconnectTimer); this.wsReconnectTimer = null; } |
| | | if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)) { try { this.ws.close(); } catch (e) {} } |
| | | }, |
| | | watch: { |
| | | lev(newLev) { |
| | |
| | | this.getMap(); |
| | | }, |
| | | createMapData(map) { |
| | | this.pixiStageList = [map.length]; |
| | | this.pixiStaMap = new Map(); |
| | | if (window.gsap) { |
| | | this.pixiStaMap && this.pixiStaMap.forEach((s) => { try { window.gsap.killTweensOf(s); } catch (e) {} }); |
| | | this.pixiCrnMap && this.pixiCrnMap.forEach((s) => { try { window.gsap.killTweensOf(s); } catch (e) {} }); |
| | | this.pixiDualCrnMap && this.pixiDualCrnMap.forEach((s) => { try { window.gsap.killTweensOf(s); } catch (e) {} }); |
| | | this.pixiRgvMap && this.pixiRgvMap.forEach((s) => { try { window.gsap.killTweensOf(s); } catch (e) {} }); |
| | | } |
| | | this.objectsContainer.removeChildren(); |
| | | this.objectsContainer2.removeChildren(); |
| | | if (this.tracksContainer) { this.tracksContainer.removeChildren(); } |
| | | if (this.shelvesContainer) { this.shelvesContainer.removeChildren(); } |
| | | this.crnList = []; |
| | | this.dualCrnList = []; |
| | | this.rgvList = []; |
| | | this.pixiCrnMap = new Map(); |
| | | this.pixiDualCrnMap = new Map(); |
| | | this.pixiRgvMap = new Map(); |
| | | this.pixiStaMap = new Map(); |
| | | this.pixiStageList = []; |
| | | this.pixiStageList = [map.length]; |
| | | const bayHeightList = this.initHeight(map); |
| | | const bayWidthList = this.initWidth(map); |
| | | map.forEach((item, index) => { |
| | |
| | | this.createMapData(JSON.parse(res.data)); |
| | | }, |
| | | webSocketOnOpen(e) { |
| | | if (this.wsReconnectTimer) { clearTimeout(this.wsReconnectTimer); this.wsReconnectTimer = null; } |
| | | this.wsReconnectAttempts = 0; |
| | | this.getMap(this.currentLev); |
| | | }, |
| | | webSocketOnError(e) { |
| | | this.scheduleReconnect(); |
| | | }, |
| | | webSocketOnMessage(e) { |
| | | const result = JSON.parse(e.data); |
| | |
| | | } |
| | | }, |
| | | webSocketClose(e) { |
| | | this.scheduleReconnect(); |
| | | }, |
| | | sendWs(message) { |
| | | if (this.ws && this.ws.readyState === WebSocket.OPEN) { |
| | | this.ws.send(message); |
| | | } |
| | | }, |
| | | connectWs() { |
| | | if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)) { return; } |
| | | this.ws = new WebSocket("ws://" + window.location.host + baseUrl + "/console/websocket"); |
| | | this.ws.onopen = this.webSocketOnOpen; |
| | | this.ws.onerror = this.webSocketOnError; |
| | | this.ws.onmessage = this.webSocketOnMessage; |
| | | this.ws.onclose = this.webSocketClose; |
| | | }, |
| | | scheduleReconnect() { |
| | | if (this.wsReconnectTimer) { return; } |
| | | const attempt = this.wsReconnectAttempts + 1; |
| | | const jitter = Math.floor(Math.random() * 300); |
| | | const delay = Math.min(this.wsReconnectMaxDelay, this.wsReconnectBaseDelay * Math.pow(2, this.wsReconnectAttempts)) + jitter; |
| | | this.wsReconnectTimer = setTimeout(() => { |
| | | this.wsReconnectTimer = null; |
| | | this.wsReconnectAttempts = attempt; |
| | | this.connectWs(); |
| | | }, delay); |
| | | }, |
| | | createShelfSprite(width, height) { |
| | | let idx = width + "-" + height; |
| | | let texture = this.pixiShelfMap.get(idx); |