src/websocket/websocket.js
@@ -16,13 +16,13 @@ * 发起websocket连接 * @param {Object} agentData 需要向后台传递的参数数据 */ function websocketSend (agentData) { export function websocketSend (agentData) { // 加延迟是为了尽量让ws连接状态变为OPEN setTimeout(() => { // 添加状态判断,当为OPEN时,发送消息 if (websock.readyState === websock.OPEN) { // websock.OPEN = 1 // 发给后端的数据需要字符串化 websock.send(JSON.stringify(agentData)) websock.send(agentData) console.log('连接成功'); } if (websock.readyState === websock.CLOSED) { // websock.CLOSED = 3