1 line
11 KiB
JSON
1 line
11 KiB
JSON
{"remainingRequest":"E:\\视频边缘计算管理平台\\TransFlow\\node_modules\\babel-loader\\lib\\index.js!E:\\视频边缘计算管理平台\\TransFlow\\src\\utils\\mqttConfig.js","dependencies":[{"path":"E:\\视频边缘计算管理平台\\TransFlow\\src\\utils\\mqttConfig.js","mtime":1675039406917},{"path":"E:\\视频边缘计算管理平台\\TransFlow\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"E:\\视频边缘计算管理平台\\TransFlow\\node_modules\\babel-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import _objectWithoutProperties from \"E:/\\u89C6\\u9891\\u8FB9\\u7F18\\u8BA1\\u7B97\\u7BA1\\u7406\\u5E73\\u53F0/TransFlow/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _classCallCheck from \"E:/\\u89C6\\u9891\\u8FB9\\u7F18\\u8BA1\\u7B97\\u7BA1\\u7406\\u5E73\\u53F0/TransFlow/node_modules/@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"E:/\\u89C6\\u9891\\u8FB9\\u7F18\\u8BA1\\u7B97\\u7BA1\\u7406\\u5E73\\u53F0/TransFlow/node_modules/@babel/runtime/helpers/esm/createClass\";\nimport mqtt from \"mqtt\";\nimport Vue from 'vue';\nvar vm = new Vue();\n\nvar mqttHandle = /*#__PURE__*/function () {\n function mqttHandle() {\n _classCallCheck(this, mqttHandle);\n\n var newName = localStorage.getItem('ms_username');\n this.connect = {\n host: vm.mqttHost,\n port: vm.mqttPort,\n endpoint: \"/mqtt\",\n clean: true,\n // 保留会话\n cleanSession: true,\n connectTimeout: 7000,\n // 超时时间\n reconnectPeriod: 7000,\n // 重连时间间隔\n // 认证信息\n // clientId: Number(new Date()).toString(),\n clientId: newName,\n username: \"admin\",\n password: \"123456\"\n }; // this.subscription = {\n // topic: subscribe, //需要传入数组的包含订阅的名称\n // qos: 0,\n // }\n\n this.mqttClient = null;\n }\n /**\r\n * 创建链接\r\n * @returns client\r\n */\n\n\n _createClass(mqttHandle, [{\n key: \"createConnect\",\n value: function createConnect(onConnected) {\n //配置链接\n var _this$connect = this.connect,\n host = _this$connect.host,\n port = _this$connect.port,\n endpoint = _this$connect.endpoint,\n options = _objectWithoutProperties(_this$connect, [\"host\", \"port\", \"endpoint\"]); // const connectUrl = `ws://${this.connect.host}:${this.connect.port}${this.connect.endpoint}`;\n\n\n var connectUrl = 'ws://172.16.1.168:10087/'; // if (!client.connected) {\n // client.on('connect', function () {\n // console.log('连接成功')\n // })\n // } else {\n // client.publish('test/clientE', ms, {'qos': 2}, function (err) {\n // if (err) {\n // console.log(err)\n // }\n // })\n // }\n\n if (this.mqttClient == undefined) {\n this.mqttClient = mqtt.connect(connectUrl, options);\n this.mqttClient.on(\"connect\", function () {\n console.log(\"Connection succeeded!\");\n onConnected(); // this._client.subscribe('img'+this.number, { qos: 0 });\n // this._client.subscribe('stream'+this.number, { qos: 0 });\n // this._client.subscribe('trajectory'+this.number, { qos: 0 });\n // this._client.subscribe('detection'+this.number, { qos: 0 });\n // this._client.subscribe('img0', { qos: 0 });\n // this._client.subscribe('stream0', { qos: 0 });\n // this._client.subscribe('trajectory0', { qos: 0 });\n // this._client.subscribe('detection0', { qos: 0 });\n });\n this.mqttClient.on('reconnect', function (error) {\n console.log('正在重连');\n });\n this.mqttClient.on(\"error\", function (error) {\n console.log(\"Connection failed\");\n }); //配置topic\n // const { topic, qos } = this.subscription;\n // console.log(topic, qos,'topic, qos');\n // this._client.subscribe(topic, { qos: qos }, (error, res) => {\n // if (error) {\n // console.log(\"Subscribe to topics error\", error);\n // return;\n // }\n // this.subscribeSuccess = true;\n // console.log(\"Subscribe to topics res\", res[0].qos, res[0].topic);\n // });\n }\n\n return this.mqttClient; // try {\n // } catch (error) {\n // console.log(\"mqtt.connect error\", error);\n // }\n }\n }, {\n key: \"MySub\",\n value: function MySub(subscriptions) {\n //['hert','img0','img1','img2','img3','img4','img5','img6','img7']\n this.mqttClient.subscribe(subscriptions, {\n qos: 0\n }, function (err) {\n if (!err) {\n console.log(\"订阅成功:\" + subscriptions);\n } else {\n console.log('消息订阅失败!' + subscriptions);\n }\n });\n }\n }, {\n key: \"MyUnSub\",\n value: function MyUnSub(subscription) {}\n }]);\n\n return mqttHandle;\n}();\n\nexport default mqttHandle;",{"version":3,"sources":["E:/视频边缘计算管理平台/TransFlow/src/utils/mqttConfig.js"],"names":["mqtt","Vue","vm","mqttHandle","newName","localStorage","getItem","connect","host","mqttHost","port","mqttPort","endpoint","clean","cleanSession","connectTimeout","reconnectPeriod","clientId","username","password","mqttClient","onConnected","options","connectUrl","undefined","on","console","log","error","subscriptions","subscribe","qos","err","subscription"],"mappings":";;;AAAA,OAAOA,IAAP,MAAiB,MAAjB;AACA,OAAOC,GAAP,MAAgB,KAAhB;AACA,IAAIC,EAAE,GAAG,IAAID,GAAJ,EAAT;;IAEME,U;AACF,wBAAc;AAAA;;AACV,QAAIC,OAAO,GAAGC,YAAY,CAACC,OAAb,CAAqB,aAArB,CAAd;AACA,SAAKC,OAAL,GAAe;AACXC,MAAAA,IAAI,EAAEN,EAAE,CAACO,QADE;AAEXC,MAAAA,IAAI,EAAER,EAAE,CAACS,QAFE;AAGXC,MAAAA,QAAQ,EAAE,OAHC;AAIXC,MAAAA,KAAK,EAAE,IAJI;AAIE;AACbC,MAAAA,YAAY,EAAE,IALH;AAMXC,MAAAA,cAAc,EAAE,IANL;AAMW;AACtBC,MAAAA,eAAe,EAAE,IAPN;AAOY;AACvB;AACA;AACAC,MAAAA,QAAQ,EAAEb,OAVC;AAWXc,MAAAA,QAAQ,EAAE,OAXC;AAYXC,MAAAA,QAAQ,EAAE;AAZC,KAAf,CAFU,CAgBV;AACA;AACA;AACA;;AACA,SAAKC,UAAL,GAAkB,IAAlB;AACH;AACD;;;;;;;;kCAIcC,W,EAAa;AACvB;AADuB,0BAEsB,KAAKd,OAF3B;AAAA,UAEfC,IAFe,iBAEfA,IAFe;AAAA,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;;;;;;AAIL,eAAe9B,UAAf","sourcesContent":["import mqtt from \"mqtt\";\r\nimport Vue from 'vue'\r\nvar vm = new Vue();\r\n\r\nclass mqttHandle {\r\n constructor() {\r\n var newName = localStorage.getItem('ms_username')\r\n this.connect = {\r\n host: vm.mqttHost,\r\n port: vm.mqttPort,\r\n endpoint: \"/mqtt\",\r\n clean: true, // 保留会话\r\n cleanSession: true,\r\n connectTimeout: 7000, // 超时时间\r\n reconnectPeriod: 7000, // 重连时间间隔\r\n // 认证信息\r\n // clientId: Number(new Date()).toString(),\r\n clientId: newName,\r\n username: \"admin\",\r\n password: \"123456\",\r\n }\r\n // this.subscription = {\r\n // topic: subscribe, //需要传入数组的包含订阅的名称\r\n // qos: 0,\r\n // }\r\n this.mqttClient = null;\r\n }\r\n /**\r\n * 创建链接\r\n * @returns client\r\n */\r\n createConnect(onConnected) {\r\n //配置链接\r\n const { host, port, endpoint, ...options } = this.connect;\r\n // const connectUrl = `ws://${this.connect.host}:${this.connect.port}${this.connect.endpoint}`;\r\n const connectUrl = 'ws://172.16.1.168:10087/';\r\n // if (!client.connected) {\r\n // client.on('connect', function () {\r\n // console.log('连接成功')\r\n // })\r\n // } else {\r\n // client.publish('test/clientE', ms, {'qos': 2}, function (err) {\r\n // if (err) {\r\n // console.log(err)\r\n // }\r\n // })\r\n // }\r\n if (this.mqttClient == undefined)\r\n {\r\n this.mqttClient = mqtt.connect(connectUrl, options);\r\n this.mqttClient.on(\"connect\", () => {\r\n console.log(\"Connection succeeded!\");\r\n onConnected();\r\n // this._client.subscribe('img'+this.number, { qos: 0 });\r\n // this._client.subscribe('stream'+this.number, { qos: 0 });\r\n // this._client.subscribe('trajectory'+this.number, { qos: 0 });\r\n // this._client.subscribe('detection'+this.number, { qos: 0 });\r\n // this._client.subscribe('img0', { qos: 0 });\r\n // this._client.subscribe('stream0', { qos: 0 });\r\n // this._client.subscribe('trajectory0', { qos: 0 });\r\n // this._client.subscribe('detection0', { qos: 0 });\r\n });\r\n this.mqttClient.on('reconnect', (error) => {\r\n console.log('正在重连')\r\n })\r\n this.mqttClient.on(\"error\", (error) => {\r\n console.log(\"Connection failed\");\r\n });\r\n \r\n //配置topic\r\n // const { topic, qos } = this.subscription;\r\n // console.log(topic, qos,'topic, qos');\r\n // this._client.subscribe(topic, { qos: qos }, (error, res) => {\r\n // if (error) {\r\n // console.log(\"Subscribe to topics error\", error);\r\n // return;\r\n // }\r\n // this.subscribeSuccess = true;\r\n // console.log(\"Subscribe to topics res\", res[0].qos, res[0].topic);\r\n // });\r\n }\r\n\r\n return this.mqttClient;\r\n \r\n // try {\r\n \r\n \r\n // } catch (error) {\r\n // console.log(\"mqtt.connect error\", error);\r\n // }\r\n \r\n }\r\n\r\n MySub(subscriptions)\r\n {\r\n //['hert','img0','img1','img2','img3','img4','img5','img6','img7']\r\n this.mqttClient.subscribe(subscriptions, { qos: 0 }, (err)=>\r\n {\r\n if (!err) {\r\n console.log(\"订阅成功:\"+subscriptions);\r\n \r\n } else {\r\n console.log('消息订阅失败!'+subscriptions)\r\n }\r\n });\r\n }\r\n\r\n MyUnSub(subscription)\r\n {\r\n\r\n }\r\n\r\n\r\n}\r\nexport default mqttHandle;"]}]} |