import { movedevicewebsocketurl } from "../../../public/js/url.js"; import {connectWebsocket,stationInfoTableList} from "../js/index.js"; import { drawMoveDeviceMarker } from "../js/marker/moveDeviceMarker.js"; import {playDeviceSosAudio,stopDeviceSosAudio} from "../audio/audio.js"; import { showStationIpcRightVideo } from "../js/schoolBaseInfo.js"; import { autoOpenRightSlide } from "../js/pageEventTool.js"; import {updateMarkerLatlng,setMoveDeviceAlarmNormalIcon,deleteOneMoveDeviceMarkerHash,closemdevAlarmIndex} from "../js/marker/moveDeviceMarker.js" import { createSchoolTree } from "../js/tree.js"; import { getAlarmListbyScopeReq } from "../js/showAlarmListTable.js"; import { showAlarmAllList } from "../js/showAlarmListTable.js"; import { addMoveDeviceAlarmMarker, delMoveDeviceAlarmMarker } from "../js/marker/moveDeviceEventMarker.js"; let mdWsFlag = 60; let mdWsTimer = null; let mdWebsocketConnect = null; let deviceHash={}; function moveDeviceWebsocket(){ return new Promise((resolve, reject) => { mdWebsocketConnect = new WebSocket(movedevicewebsocketurl); mdWebsocketConnect.onopen = function (evt) { mdWsFlag = 3; if (mdWsTimer != null) { clearInterval(mdWsTimer); mdWsTimer = null; mdWsFlag=60; } resolve({ "msg":"移动设备websocket连接成功", "code":0, "mdWebsocketConnect":mdWebsocketConnect }) setInterval(()=>{ let messageObj = { "msgcode": 99, "msgname": "hb", "message":"hb" } if(mdWebsocketConnect!=null){ mdWebsocketConnect.send(JSON.stringify(messageObj)); } },5000) }; mdWebsocketConnect.onclose = function (evt) { console.log("移动设备的websocket已经断开onclose"); mdWebsocketConnect.close(); mdevWebsocketReconnection(); }; mdWebsocketConnect.onerror = function (evt) { console.log("移动设备的websocket已经断开onerror") mdWebsocketConnect.close(); mdevWebsocketReconnection(); }; mdWebsocketConnect.onmessage = function (evt) { var data=JSON.parse(evt.data); var msgcode=data["msgcode"]; var message=data["message"]; if(msgcode=="4000"){//设备心跳 websoceketDeviceBear(message); }else if(msgcode=="4001"){//这是普通的事件 //查询设备的事件跟报警 mdevEventSos(message); }else if(msgcode=="4002"){//设备在线,离线状态 deviceStatusUpdate(message); }else if(msgcode=="403"){//获取移动设备的设备列表 //这里需要判断一下,如果是重连,就不做任何事情,只需要连接一下 var list=message["list"]; var pagepro=message["pagepro"]; if(list!=null){ for(var dev=0;dev3){ deviceHash[deviceid]["appVersion"]=infoArr[3]; }else{ deviceHash[deviceid]["appVersion"]="未知"; } }else{ var infoArr=[]; deviceHash[deviceid]["cardNumber"]=""; deviceHash[deviceid]["appVersion"]="未知"; } }else{ var infoArr=[]; deviceHash[deviceid]["cardNumber"]=""; deviceHash[deviceid]["appVersion"]="未知"; } //判断是否越界 if(message[i]["status"].length!=0){ if(message[i]["status"].indexOf("[")!=-1){ var data=JSON.parse(message[i]["status"]); if(message[i]["status"].indexOf("statusext")!=-1){//找到了这个字段,新的协议 for(var s=0;s