yudao-dev/src/views/OperationalOverview/wsInterface.js
2024-01-30 18:08:59 +08:00

52 lines
1.3 KiB
JavaScript

import { WsConnect } from './websocket'
import store from "@/store";
// 创建websocket链接
const timestr = new Date().getTime()
// ISRA
const mesIsra = new WsConnect(
process.env.VUE_APP_Socket_API + '/websocket/message?userId=KILN'+timestr,
'',
(data) => {
// console.log('mes ISRA成功的回调函数, 接收到的data数据: ', data)
let msgData = JSON.parse(data)
// console.log(msgData)
if (msgData == null) return;
switch (msgData?.type) {
case "israKiln": {
store.dispatch({type: "websocket/setIsraKiln", payload:msgData.detData.dayStatistic})
break;
}
default:
}
},
(err) => {
console.log('失败的回调函数', err)
}
)
export const getDcsMsg = () => {
// dcsConn.createWebSoket()
mesIsra.createWebSoket()
// mesMA.createWebSoket()
// mesEN.createWebSoket()
// mesGAS.createWebSoket()
// mesIS.createWebSoket()
// mesSJG.createWebSoket()
// mesOV.createWebSoket()
// mesCUTTING.createWebSoket()
}
export const closeDcsMsg = () => {
// dcsConn.closeWebsocket()
mesIsra.closeWebsocket()
// mesMA.closeWebsocket()
// mesEN.closeWebsocket()
// mesGAS.closeWebsocket()
// mesIS.closeWebsocket()
// mesSJG.closeWebsocket()
// mesOV.closeWebsocket()
// mesCUTTING.closeWebsocket()
}