Commit 82f2d7a3 authored by SQL_Mou's avatar SQL_Mou

与Android互相调用方法,增加socket长连接

parent 4391a46f
......@@ -234,6 +234,70 @@ export default {
},
methods:{
// getSerialSend() {
// //console.log(123);
// window.SerialPort.send("hello");
// },
// getSerialReceive() {
// //console.log(123);
// let cont = "";
// cont = window.SerialPort.receive()
// window.alert(cont);
// },
// //初始化weosocket
// initWebSocket(){
// const wsuri = "ws://8.143.203.103:9095";//连接地址,可加参数
// // const wsuri = process.env.VUE_APP_WS_API + "/" + 'pcBigScreen';
// this.websocket = new WebSocket(wsuri);
// this.websocket.onopen = this.websocketonopen;
// this.websocket.onerror = this.websocketonerror;
// this.websocket.onmessage = this.websocketonmessage;
// this.websocket.onclose = this.websocketclose;
// this.websocketonmessage();
// },
// //WebSocket连接成功
// websocketonopen() {
// console.log("WebSocket连接成功");
// },
// //WebSocket连接错误
// websocketonerror(e) {
// console.log("WebSocket连接发生错误");
// },
// //WebSocket数据接收
// websocketonmessage(e){
// //console.log("e",e);
// if(e == undefined){
// return
// }else{
// let obj1 = JSON.parse(e.data);
// console.log(obj1);
// }
// },
// //WebSocket数据发送
// websocketsend(agentData){
// this.websocket.send(agentData);
// },
// //WebSocket关闭
// websocketclose(e){
// //console.log("connection closed (" + e.code + ")");
// console.log("connection closed !");
// },
// //WebSocket重连
// reconnect(){
// var This=this;
// if (this.websocket.readyState === 1) { // that.websock.readyState = 1 表示连接成功,可以立即发送信息
// This.websocketonmessage();
// } else if (this.websocket.readyState === 0) { // 表示正在连接,设置300ms后发送信息
// setTimeout(function () {
// This.websocketonmessage();
// }, 300);
// } else { // 连接未创建或者创建失败,则重新创建连接,并设置500ms后发送信息
// This.initWebSocket();
// setTimeout(function () {
// This.websocketonmessage();
// }, 500);
// }
// },
loadData(){
let that = this;
let href1 = window.location.href;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment