<reponame>pxy0113/lhds
{"remainingRequest":"F:\\work\\lhds\\node_modules\\thread-loader\\dist\\cjs.js!F:\\work\\lhds\\node_modules\\babel-loader\\lib\\index.js!F:\\work\\lhds\\node_modules\\eslint-loader\\index.js??ref--13-0!F:\\work\\lhds\\src\\plugins\\socket.js","dependencies":[{"path":"F:\\work\\lhds\\src\\plugins\\socket.js","mtime":1573807218727},{"path":"F:\\work\\lhds\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"F:\\work\\lhds\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"F:\\work\\lhds\\node_modules\\babel-loader\\lib\\index.js","mtime":499162500000},{"path":"F:\\work\\lhds\\node_modules\\eslint-loader\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["var websock = null;\nvar state = -1;\nimport vuex from \"../store/index\";\nexport default {\n  initWebSocket: function initWebSocket() {\n    var _this = this;\n\n    //初始化weosocket\n    var token = sessionStorage.token;\n\n    if (token) {\n      var ds = window.encodeURIComponent(token); // const wsuri = `ws://192.168.2.105:8080/EasRobotWS/ws?token=${ds}`;\n\n      var wsuri = \"ws://ws.lhds.vip:8080/EasRobotWS/ws?token=\".concat(ds); // const wsuri = `ws://m252t77964.wicp.vip:20211/EasRobotWS/ws?token=${ds}`\n\n      websock = new WebSocket(wsuri);\n      state = websock.readyState;\n\n      websock.onmessage = function (e) {\n        _this.websocketonmessage(e);\n      };\n\n      websock.onopen = function () {\n        _this.websocketonopen();\n      };\n\n      websock.onerror = function () {\n        console.log('失败了');\n      };\n\n      websock.onclose = function (e) {\n        _this.websocketclose(e);\n      };\n    }\n  },\n  websocketonmessage: function websocketonmessage(e) {\n    var result = JSON.parse(e.data);\n    console.log('收到数据 = >', result);\n    state = websock.readyState;\n    vuex.state.collocationList = result;\n  },\n  websocketonopen: function websocketonopen() {\n    console.log('打开websocket'); //this.websocketsend();\n\n    state = websock.readyState;\n  },\n  websocketclose: function websocketclose(e) {\n    //关闭\n    console.log('断开连接', e);\n    vuex.state.collocationList = [];\n    state = -1;\n  },\n  websocketsend: function websocketsend(Data) {\n    //数据发送\n    console.log('发送数据 = >', Data);\n    websock.send(Data);\n  },\n  close: function close() {\n    if (state >= 0) {\n      websock.close();\n      state = websock.readyState; // state = -1;\n      // console.log(state)\n    }\n  },\n  lookState: function lookState() {\n    //查询sock当前状态\n    return state;\n  }\n};",null]}