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