| | |
| | | if (!window.WebSocket) { |
| | | return; |
| | | } |
| | | if (that.socket.readyState == WebSocket.OPEN) { |
| | | that.socket.send(that.userId); |
| | | |
| | | if (window.WebSocket) { |
| | | window.socket = new WebSocket("ws://36.134.81.48:9034/websocket"); |
| | | window.socket.onmessage = function (event) { |
| | | }; |
| | | |
| | | window.socket.onopen = function (event) { |
| | | }; |
| | | |
| | | window.socket.onclose = function (event) { |
| | | }; |
| | | } else { |
| | | console.log("WebSocket连接没有建立成功!!"); |
| | | } |
| | | }, 4000); |
| | | |
| | | axios({ |
| | | url: "/api/blade-jfpts/alarm/alarm/getLimit", |
| | | method: "get", |
| | | }).then(function (response) { |
| | | that.deviceId = response.data.data[0].id; |
| | | //获得最新ID,开启实时报警循环 |
| | | that.layerRealtime(); |
| | | }); |
| | | }, |
| | | layerRealtime() { |
| | | var that = this; |
| | | window.clearTimeout(window.realTimeQuery); |
| | | // that.deviceId = 334; // 测试用 |
| | | window.realTimeQuery = setInterval(function () { |
| | | setTimeout(function () { |
| | | if(!window.WebSocket){ |
| | | return; |
| | | } |
| | | if(window.socket.readyState == WebSocket.OPEN){ |
| | | window.socket.send(that.userId); |
| | | }else{ |
| | | console.log("WebSocket连接没有建立成功!!"); |
| | | } |
| | | }, 2000); |
| | | |
| | | |
| | | axios({ |
| | | url: "/api/blade-jfpts/alarm/alarm/selecttx?id=" + that.deviceId, |
| | | method: "post", |