|
|
@ -646,20 +646,20 @@ export default {
|
|
|
|
alert("您的浏览器不支持Websocket通信协议")
|
|
|
|
alert("您的浏览器不支持Websocket通信协议")
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let url = "ws://10.11.41.249:8080/websocket/message"; //请求的后端地址
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let websocket = null;//全局WebSocket对象
|
|
|
|
const getWebsocket = () => {
|
|
|
|
let lockReconnect = false; // 网络断开重连
|
|
|
|
let websocket = new WebSocket("ws://10.11.41.249:8080/websocket/message")
|
|
|
|
let wsCreateHandler = null; // 创建连接
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
websocket = new WebSocket(url)
|
|
|
|
|
|
|
|
websocket.onopen = function (event) {
|
|
|
|
websocket.onopen = function (event) {
|
|
|
|
console.log("服务已连接")
|
|
|
|
console.log("服务已连接")
|
|
|
|
};
|
|
|
|
};
|
|
|
|
websocket.onmessage = function (event) {
|
|
|
|
websocket.onmessage = function (event) {
|
|
|
|
console.log(event)
|
|
|
|
console.log(event)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
websocket.onerror = function (event) {
|
|
|
|
|
|
|
|
setTimeout(getWebsocket,1000)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getWebsocket()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|