gis-common 1.0.18 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/resource.min.js +60 -267
- package/package.json +35 -35
package/dist/resource.min.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
2
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory(
|
|
3
|
+
module.exports = factory();
|
|
4
4
|
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define("Gis", [
|
|
5
|
+
define("Gis", [], factory);
|
|
6
6
|
else if(typeof exports === 'object')
|
|
7
|
-
exports["Gis"] = factory(
|
|
7
|
+
exports["Gis"] = factory();
|
|
8
8
|
else
|
|
9
|
-
root["Gis"] = factory(
|
|
10
|
-
})(window, function(
|
|
9
|
+
root["Gis"] = factory();
|
|
10
|
+
})(window, function() {
|
|
11
11
|
return /******/ (function(modules) { // webpackBootstrap
|
|
12
12
|
/******/ // The module cache
|
|
13
13
|
/******/ var installedModules = {};
|
|
@@ -91,17 +91,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
91
91
|
/******/
|
|
92
92
|
/******/
|
|
93
93
|
/******/ // Load entry module and return exports
|
|
94
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
94
|
+
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
|
95
95
|
/******/ })
|
|
96
96
|
/************************************************************************/
|
|
97
97
|
/******/ ([
|
|
98
98
|
/* 0 */
|
|
99
|
-
/***/ (function(module, exports) {
|
|
100
|
-
|
|
101
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
|
|
102
|
-
|
|
103
|
-
/***/ }),
|
|
104
|
-
/* 1 */
|
|
105
99
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
106
100
|
|
|
107
101
|
"use strict";
|
|
@@ -130,7 +124,6 @@ __webpack_require__.d(__webpack_exports__, "CanvasDrawer", function() { return /
|
|
|
130
124
|
__webpack_require__.d(__webpack_exports__, "ElQuery", function() { return /* reexport */ core_ElQuery; });
|
|
131
125
|
__webpack_require__.d(__webpack_exports__, "EventDispatcher", function() { return /* reexport */ core_EventDispatcher; });
|
|
132
126
|
__webpack_require__.d(__webpack_exports__, "HashMap", function() { return /* reexport */ core_HashMap; });
|
|
133
|
-
__webpack_require__.d(__webpack_exports__, "MqttClient", function() { return /* reexport */ core_MqttClient; });
|
|
134
127
|
__webpack_require__.d(__webpack_exports__, "WebSocketClient", function() { return /* reexport */ core_WebSocketClient; });
|
|
135
128
|
__webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /* reexport */ core_WebStorage; });
|
|
136
129
|
|
|
@@ -316,7 +309,7 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
316
309
|
* @param {*} json
|
|
317
310
|
* @returns {*}
|
|
318
311
|
*/
|
|
319
|
-
|
|
312
|
+
jsontoQuery: function jsontoQuery(json) {
|
|
320
313
|
var tempArr = [];
|
|
321
314
|
for (var i in json) {
|
|
322
315
|
var key = i;
|
|
@@ -717,22 +710,22 @@ Array.prototype.clear = function () {
|
|
|
717
710
|
|
|
718
711
|
var exp = new Date();
|
|
719
712
|
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
|
|
720
|
-
document.cookie = name +
|
|
713
|
+
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
|
|
721
714
|
},
|
|
722
715
|
remove: function remove(name) {
|
|
723
716
|
var exp = new Date();
|
|
724
717
|
exp.setTime(exp.getTime() - 1);
|
|
725
|
-
var cval =
|
|
718
|
+
var cval = getCookie(name);
|
|
726
719
|
if (cval != null) {
|
|
727
|
-
document.cookie = name +
|
|
720
|
+
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
|
|
728
721
|
}
|
|
729
722
|
},
|
|
730
723
|
get: function get(name) {
|
|
731
|
-
var arr = document.cookie.match(new RegExp(
|
|
724
|
+
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
|
|
732
725
|
if (arr != null) {
|
|
733
726
|
return arr[2];
|
|
734
727
|
} else {
|
|
735
|
-
return
|
|
728
|
+
return "";
|
|
736
729
|
}
|
|
737
730
|
}
|
|
738
731
|
});
|
|
@@ -1493,7 +1486,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1493
1486
|
}
|
|
1494
1487
|
});
|
|
1495
1488
|
// CONCATENATED MODULE: ./src/utils/StringUtils.js
|
|
1496
|
-
|
|
1497
1489
|
/* harmony default export */ var StringUtils = ({
|
|
1498
1490
|
/**
|
|
1499
1491
|
* 常用正则验证
|
|
@@ -1611,62 +1603,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1611
1603
|
return str;
|
|
1612
1604
|
}
|
|
1613
1605
|
},
|
|
1614
|
-
|
|
1615
|
-
/**
|
|
1616
|
-
* 处理字符串模板
|
|
1617
|
-
* eg: tag`${abc}`
|
|
1618
|
-
* @param {*} strArray
|
|
1619
|
-
* @param {*} args
|
|
1620
|
-
* @returns {*}
|
|
1621
|
-
*/
|
|
1622
1606
|
tag: function tag(strArray) {
|
|
1623
1607
|
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1624
1608
|
args[_key - 1] = arguments[_key];
|
|
1625
1609
|
}
|
|
1626
1610
|
|
|
1627
1611
|
args = args.map(function (val) {
|
|
1628
|
-
|
|
1629
|
-
case 'Object':
|
|
1630
|
-
return val || '{}';
|
|
1631
|
-
case 'Array':
|
|
1632
|
-
return val || '[]';
|
|
1633
|
-
default:
|
|
1634
|
-
return val || '';
|
|
1635
|
-
}
|
|
1612
|
+
return val || '';
|
|
1636
1613
|
});
|
|
1637
1614
|
return strArray.reduce(function (prev, next, index) {
|
|
1638
1615
|
return '' + prev + args[index - 1] + next;
|
|
1639
1616
|
});
|
|
1640
|
-
},
|
|
1641
|
-
|
|
1642
|
-
/**
|
|
1643
|
-
* 获取字符串字节长度
|
|
1644
|
-
* @param {*} str
|
|
1645
|
-
* @returns {*}
|
|
1646
|
-
*/
|
|
1647
|
-
getByteLength: function getByteLength(str) {
|
|
1648
|
-
return str.replace(/[\u0391-\uFFE5]/g, 'aa').length;
|
|
1649
|
-
},
|
|
1650
|
-
|
|
1651
|
-
/**
|
|
1652
|
-
* 根据字节长度截取字符串
|
|
1653
|
-
* @param {*} str
|
|
1654
|
-
* @param {*} n
|
|
1655
|
-
* @returns {*}
|
|
1656
|
-
*/
|
|
1657
|
-
subStringByte: function subStringByte(str, n) {
|
|
1658
|
-
var r = /[^\x00-\xff]/g;
|
|
1659
|
-
if (str.replace(r, 'mm').length <= n) {
|
|
1660
|
-
return str;
|
|
1661
|
-
}
|
|
1662
|
-
var m = Math.floor(n / 2);
|
|
1663
|
-
for (var i = m; i < str.length; i++) {
|
|
1664
|
-
var sub = str.substring(0, i);
|
|
1665
|
-
if (sub.replace(r, 'mm').length >= n) {
|
|
1666
|
-
return sub;
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
return str;
|
|
1670
1617
|
}
|
|
1671
1618
|
});
|
|
1672
1619
|
// CONCATENATED MODULE: ./src/utils/index.js
|
|
@@ -2092,184 +2039,27 @@ var HashMap = function () {
|
|
|
2092
2039
|
}();
|
|
2093
2040
|
|
|
2094
2041
|
/* harmony default export */ var core_HashMap = (HashMap);
|
|
2095
|
-
// EXTERNAL MODULE: external "mqtt"
|
|
2096
|
-
var external_mqtt_ = __webpack_require__(0);
|
|
2097
|
-
|
|
2098
|
-
// CONCATENATED MODULE: ./src/core/MqttClient.js
|
|
2099
|
-
var MqttClient_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
2100
|
-
|
|
2101
|
-
function MqttClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2102
|
-
|
|
2103
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
2104
|
-
|
|
2105
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
var MqttClient_MqttClient = function (_EventDispatcher) {
|
|
2114
|
-
_inherits(MqttClient, _EventDispatcher);
|
|
2115
|
-
|
|
2116
|
-
/**
|
|
2117
|
-
* Creates an instance of MqttClient.
|
|
2118
|
-
* @param {*} config mqtt实例参数
|
|
2119
|
-
*/
|
|
2120
|
-
function MqttClient() {
|
|
2121
|
-
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2122
|
-
|
|
2123
|
-
MqttClient_classCallCheck(this, MqttClient);
|
|
2124
|
-
|
|
2125
|
-
var _this = _possibleConstructorReturn(this, (MqttClient.__proto__ || Object.getPrototypeOf(MqttClient)).call(this));
|
|
2126
|
-
|
|
2127
|
-
_this.context = CommUtils.extend(MqttClient.defaultContext, config);
|
|
2128
|
-
_this.options = {
|
|
2129
|
-
connectTimeout: _this.context.MQTT_TIMEOUTM,
|
|
2130
|
-
clientId: CommUtils.generateGuid(),
|
|
2131
|
-
username: _this.context.MQTT_USERNAME,
|
|
2132
|
-
password: _this.context.MQTT_PASSWORD,
|
|
2133
|
-
clean: true
|
|
2134
|
-
};
|
|
2135
|
-
_this.client = Object(external_mqtt_["connect"])(_this.context.MQTT_SERVICE, _this.options);
|
|
2136
|
-
_this._onConnect();
|
|
2137
|
-
_this._onMessage();
|
|
2138
|
-
MqttClient.instance = _this;
|
|
2139
|
-
return _this;
|
|
2140
|
-
}
|
|
2141
|
-
|
|
2142
|
-
MqttClient_createClass(MqttClient, [{
|
|
2143
|
-
key: "_onConnect",
|
|
2144
|
-
value: function _onConnect() {
|
|
2145
|
-
var _this2 = this;
|
|
2146
|
-
|
|
2147
|
-
this.client.on("connect", function () {
|
|
2148
|
-
console.log("链接mqtt成功==>" + _this2.context.MQTT_SERVICE);
|
|
2149
|
-
_this2.dispatchEvent({ type: EventTypeConstant.MQTT_CONNECT, message: _this2 });
|
|
2150
|
-
});
|
|
2151
|
-
this.client.on("error", function (err) {
|
|
2152
|
-
console.log("链接mqtt报错", err);
|
|
2153
|
-
_this2.dispatchEvent({ type: EventTypeConstant.MQTT_ERROR, message: _this2 });
|
|
2154
|
-
_this2.client.end();
|
|
2155
|
-
_this2.client.reconnect();
|
|
2156
|
-
});
|
|
2157
|
-
}
|
|
2158
|
-
}, {
|
|
2159
|
-
key: "_onMessage",
|
|
2160
|
-
value: function _onMessage() {
|
|
2161
|
-
var _this3 = this;
|
|
2162
|
-
|
|
2163
|
-
this.client.on("message", function (topic, message) {
|
|
2164
|
-
var dataString = message;
|
|
2165
|
-
var data = "";
|
|
2166
|
-
if (message instanceof Uint8Array) {
|
|
2167
|
-
dataString = message.toString();
|
|
2168
|
-
}
|
|
2169
|
-
try {
|
|
2170
|
-
data = JSON.parse(dataString);
|
|
2171
|
-
} catch (error) {
|
|
2172
|
-
throw new Error(ErrorTypeConstant.JSON_PARSE_ERROR);
|
|
2173
|
-
}
|
|
2174
|
-
_this3.dispatchEvent({
|
|
2175
|
-
type: EventTypeConstant.MQTT_MESSAGE,
|
|
2176
|
-
message: { topic: topic, data: data }
|
|
2177
|
-
});
|
|
2178
|
-
});
|
|
2179
|
-
}
|
|
2180
|
-
}, {
|
|
2181
|
-
key: "sendMsg",
|
|
2182
|
-
value: function sendMsg(topic, msg) {
|
|
2183
|
-
if (!this.client.connected) {
|
|
2184
|
-
console.error("客户端未连接");
|
|
2185
|
-
return;
|
|
2186
|
-
}
|
|
2187
|
-
this.client.publish(topic, msg, { qos: 1, retain: true });
|
|
2188
|
-
}
|
|
2189
|
-
}, {
|
|
2190
|
-
key: "subscribe",
|
|
2191
|
-
value: function subscribe(topic) {
|
|
2192
|
-
this.client.subscribe(topic, { qos: 1 }, function (error, res) {
|
|
2193
|
-
if (error instanceof Error || res.length === 0) {
|
|
2194
|
-
console.error("\u8BA2\u9605\u5931\u8D25==>" + topic, error);
|
|
2195
|
-
} else {
|
|
2196
|
-
console.log("\u8BA2\u9605\u6210\u529F==>" + topic);
|
|
2197
|
-
}
|
|
2198
|
-
});
|
|
2199
|
-
return this;
|
|
2200
|
-
}
|
|
2201
|
-
}, {
|
|
2202
|
-
key: "unsubscribe",
|
|
2203
|
-
value: function unsubscribe(topic) {
|
|
2204
|
-
this.client.unsubscribe(topic, { qos: 1 }, function (error, res) {
|
|
2205
|
-
if (error instanceof Error || res.length === 0) {
|
|
2206
|
-
console.error("\u53D6\u6D88\u8BA2\u9605\u5931\u8D25==>" + topic, error);
|
|
2207
|
-
} else {
|
|
2208
|
-
console.log("\u53D6\u6D88\u8BA2\u9605\u6210\u529F==>" + topic);
|
|
2209
|
-
}
|
|
2210
|
-
});
|
|
2211
|
-
return this;
|
|
2212
|
-
}
|
|
2213
|
-
}, {
|
|
2214
|
-
key: "unconnect",
|
|
2215
|
-
value: function unconnect() {
|
|
2216
|
-
this.client.end();
|
|
2217
|
-
this.client = null;
|
|
2218
|
-
this.dispatchEvent({ type: EventTypeConstant.MQTT_CLOSE, message: null });
|
|
2219
|
-
console.log("断开mqtt成功==>" + this.context.MQTT_SERVICE);
|
|
2220
|
-
}
|
|
2221
|
-
/**
|
|
2222
|
-
* @description 获取并冻结mqtt实例
|
|
2223
|
-
* @static
|
|
2224
|
-
* @param {*} [config={}]
|
|
2225
|
-
* @returns {MqttClient}
|
|
2226
|
-
*/
|
|
2227
|
-
|
|
2228
|
-
}], [{
|
|
2229
|
-
key: "getInstance",
|
|
2230
|
-
value: function getInstance() {
|
|
2231
|
-
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2232
|
-
|
|
2233
|
-
if (MqttClient.instance) {
|
|
2234
|
-
return Object.freeze(MqttClient.instance);
|
|
2235
|
-
} else {
|
|
2236
|
-
return Object.freeze(new MqttClient(config));
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
}]);
|
|
2240
|
-
|
|
2241
|
-
return MqttClient;
|
|
2242
|
-
}(core_EventDispatcher);
|
|
2243
|
-
|
|
2244
|
-
/* harmony default export */ var core_MqttClient = (MqttClient_MqttClient);
|
|
2245
|
-
|
|
2246
|
-
MqttClient_MqttClient.defaultContext = {
|
|
2247
|
-
MQTT_TIMEOUTM: 20000,
|
|
2248
|
-
MQTT_USERNAME: "iRVMS-WEB",
|
|
2249
|
-
MQTT_PASSWORD: "novasky888",
|
|
2250
|
-
MQTT_SERVICE: "ws://" + window.document.domain + ":20007/mqtt"
|
|
2251
|
-
};
|
|
2252
2042
|
// CONCATENATED MODULE: ./src/core/WebSocketClient.js
|
|
2253
2043
|
var WebSocketClient_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
2254
2044
|
|
|
2255
2045
|
function WebSocketClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2256
2046
|
|
|
2257
|
-
function
|
|
2047
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
2258
2048
|
|
|
2259
|
-
function
|
|
2049
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
2260
2050
|
|
|
2261
2051
|
|
|
2262
2052
|
|
|
2263
2053
|
|
|
2264
2054
|
var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
2265
|
-
|
|
2055
|
+
_inherits(WebSocketClient, _EventDispatcher);
|
|
2266
2056
|
|
|
2267
2057
|
function WebSocketClient() {
|
|
2268
|
-
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
2058
|
+
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ws://127.0.0.1:10088";
|
|
2269
2059
|
|
|
2270
2060
|
WebSocketClient_classCallCheck(this, WebSocketClient);
|
|
2271
2061
|
|
|
2272
|
-
var _this =
|
|
2062
|
+
var _this = _possibleConstructorReturn(this, (WebSocketClient.__proto__ || Object.getPrototypeOf(WebSocketClient)).call(this));
|
|
2273
2063
|
|
|
2274
2064
|
_this.maxCheckTimes = 10;
|
|
2275
2065
|
_this.url = url;
|
|
@@ -2283,7 +2073,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2283
2073
|
}
|
|
2284
2074
|
|
|
2285
2075
|
WebSocketClient_createClass(WebSocketClient, [{
|
|
2286
|
-
key:
|
|
2076
|
+
key: "connect",
|
|
2287
2077
|
value: function connect() {
|
|
2288
2078
|
var _this2 = this;
|
|
2289
2079
|
|
|
@@ -2291,46 +2081,49 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2291
2081
|
this.disconnect();
|
|
2292
2082
|
if (this.url) {
|
|
2293
2083
|
try {
|
|
2294
|
-
console.info(
|
|
2084
|
+
console.info("创建ws连接" + this.url);
|
|
2295
2085
|
this.client = new WebSocket(this.url);
|
|
2296
2086
|
if (this.client) {
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2087
|
+
// 当连接成功或连接失败达到最大重连次数的一半时
|
|
2088
|
+
if (!this.connectStatus && this.checkTimes === Math.floor(this.maxCheckTimes / 2) || this.connectStatus) {
|
|
2089
|
+
this.client.onopen = function (message) {
|
|
2090
|
+
_this2.dispatchEvent({
|
|
2091
|
+
type: EventTypeConstant.WEB_SOCKET_CONNECT,
|
|
2092
|
+
message: message
|
|
2093
|
+
});
|
|
2094
|
+
};
|
|
2095
|
+
this.client.onmessage = function (message) {
|
|
2096
|
+
_this2.connectStatus = true;
|
|
2097
|
+
_this2.dispatchEvent({
|
|
2098
|
+
type: EventTypeConstant.WEB_SOCKET_MESSAGE,
|
|
2099
|
+
message: message
|
|
2100
|
+
});
|
|
2101
|
+
};
|
|
2102
|
+
this.client.onclose = function (message) {
|
|
2103
|
+
_this2.dispatchEvent({
|
|
2104
|
+
type: EventTypeConstant.WEB_SOCKET_CLOSE,
|
|
2105
|
+
message: message
|
|
2106
|
+
});
|
|
2107
|
+
};
|
|
2108
|
+
this.client.onerror = function (message) {
|
|
2109
|
+
_this2.dispatchEvent({
|
|
2110
|
+
type: EventTypeConstant.WEB_SOCKET_ERROR,
|
|
2111
|
+
message: message
|
|
2112
|
+
});
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2322
2115
|
}
|
|
2323
2116
|
} catch (ex) {
|
|
2324
|
-
console.error(
|
|
2117
|
+
console.error("创建ws连接失败" + this.url + ":" + ex);
|
|
2325
2118
|
}
|
|
2326
2119
|
}
|
|
2327
2120
|
}
|
|
2328
2121
|
}, {
|
|
2329
|
-
key:
|
|
2122
|
+
key: "disconnect",
|
|
2330
2123
|
value: function disconnect() {
|
|
2331
2124
|
if (this.client) {
|
|
2332
2125
|
try {
|
|
2333
|
-
console.log(
|
|
2126
|
+
console.log("ws断开连接" + this.url);
|
|
2334
2127
|
this.client.close();
|
|
2335
2128
|
this.client = null;
|
|
2336
2129
|
} catch (ex) {
|
|
@@ -2339,7 +2132,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2339
2132
|
}
|
|
2340
2133
|
}
|
|
2341
2134
|
}, {
|
|
2342
|
-
key:
|
|
2135
|
+
key: "connCheckStatus",
|
|
2343
2136
|
value: function connCheckStatus(times) {
|
|
2344
2137
|
var _this3 = this;
|
|
2345
2138
|
|
|
@@ -2352,30 +2145,30 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2352
2145
|
}, 2000);
|
|
2353
2146
|
}
|
|
2354
2147
|
}, {
|
|
2355
|
-
key:
|
|
2148
|
+
key: "send",
|
|
2356
2149
|
value: function send(message) {
|
|
2357
2150
|
if (this.client && this.client.readyState === 1) {
|
|
2358
2151
|
this.client.send(message);
|
|
2359
2152
|
return true;
|
|
2360
2153
|
}
|
|
2361
|
-
console.error(this.url +
|
|
2154
|
+
console.error(this.url + "消息发送失败:" + message);
|
|
2362
2155
|
return false;
|
|
2363
2156
|
}
|
|
2364
2157
|
}, {
|
|
2365
|
-
key:
|
|
2158
|
+
key: "heartbeat",
|
|
2366
2159
|
value: function heartbeat() {
|
|
2367
2160
|
var _this4 = this;
|
|
2368
2161
|
|
|
2369
2162
|
setTimeout(function () {
|
|
2370
2163
|
if (_this4.client && _this4.client.readyState === 1) {
|
|
2371
|
-
_this4.send(
|
|
2164
|
+
_this4.send("HeartBeat");
|
|
2372
2165
|
}
|
|
2373
|
-
console.log(
|
|
2166
|
+
console.log("HeartBeat," + _this4.url);
|
|
2374
2167
|
setTimeout(_this4.heartbeat, 30000);
|
|
2375
2168
|
}, 1000);
|
|
2376
2169
|
}
|
|
2377
2170
|
}], [{
|
|
2378
|
-
key:
|
|
2171
|
+
key: "getInstance",
|
|
2379
2172
|
value: function getInstance() {
|
|
2380
2173
|
if (WebSocketClient.instance) {
|
|
2381
2174
|
return WebSocketClient.instance;
|
|
@@ -2384,7 +2177,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2384
2177
|
}
|
|
2385
2178
|
}
|
|
2386
2179
|
}, {
|
|
2387
|
-
key:
|
|
2180
|
+
key: "_instance",
|
|
2388
2181
|
get: function get() {
|
|
2389
2182
|
return this.getInstance();
|
|
2390
2183
|
}
|
|
@@ -2505,7 +2298,7 @@ var WebStorage_WebStorage = function () {
|
|
|
2505
2298
|
|
|
2506
2299
|
|
|
2507
2300
|
|
|
2508
|
-
|
|
2301
|
+
// export { default as MqttClient } from "./core/MqttClient";
|
|
2509
2302
|
|
|
2510
2303
|
|
|
2511
2304
|
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gis-common",
|
|
3
|
-
"description": "gis-common",
|
|
4
|
-
"main": "dist/resource.min.js",
|
|
5
|
-
"version": "1.
|
|
6
|
-
"author": "Guo.Yan <luv02@vip.qq.com>",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"private": false,
|
|
9
|
-
"scripts": {
|
|
10
|
-
"dev": "cross-env NODE_ENV=development webpack-dev-server --hot --port 7000",
|
|
11
|
-
"build": "cross-env NODE_ENV=production webpack --progress"
|
|
12
|
-
},
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"mqtt": "^4.2.8"
|
|
15
|
-
},
|
|
16
|
-
"browserslist": [
|
|
17
|
-
"> 1%",
|
|
18
|
-
"last 2 versions",
|
|
19
|
-
"not ie <= 8"
|
|
20
|
-
],
|
|
21
|
-
"files": [],
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"babel-core": "^6.26.0",
|
|
24
|
-
"babel-loader": "^7.1.2",
|
|
25
|
-
"babel-preset-env": "^1.6.0",
|
|
26
|
-
"babel-preset-stage-3": "^6.24.1",
|
|
27
|
-
"cross-env": "^5.0.5",
|
|
28
|
-
"css-loader": "^0.28.7",
|
|
29
|
-
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
30
|
-
"webpack": "^4.23.1",
|
|
31
|
-
"webpack-cli": "^4.9.1",
|
|
32
|
-
"webpack-dev-server": "^2.9.1",
|
|
33
|
-
"clean-webpack-plugin": "^4.0.0-alpha.0"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "gis-common",
|
|
3
|
+
"description": "gis-common",
|
|
4
|
+
"main": "dist/resource.min.js",
|
|
5
|
+
"version": "1.2.1",
|
|
6
|
+
"author": "Guo.Yan <luv02@vip.qq.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"private": false,
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "cross-env NODE_ENV=development webpack-dev-server --hot --port 7000",
|
|
11
|
+
"build": "cross-env NODE_ENV=production webpack --progress"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"mqtt": "^4.2.8"
|
|
15
|
+
},
|
|
16
|
+
"browserslist": [
|
|
17
|
+
"> 1%",
|
|
18
|
+
"last 2 versions",
|
|
19
|
+
"not ie <= 8"
|
|
20
|
+
],
|
|
21
|
+
"files": [],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"babel-core": "^6.26.0",
|
|
24
|
+
"babel-loader": "^7.1.2",
|
|
25
|
+
"babel-preset-env": "^1.6.0",
|
|
26
|
+
"babel-preset-stage-3": "^6.24.1",
|
|
27
|
+
"cross-env": "^5.0.5",
|
|
28
|
+
"css-loader": "^0.28.7",
|
|
29
|
+
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
30
|
+
"webpack": "^4.23.1",
|
|
31
|
+
"webpack-cli": "^4.9.1",
|
|
32
|
+
"webpack-dev-server": "^2.9.1",
|
|
33
|
+
"clean-webpack-plugin": "^4.0.0-alpha.0"
|
|
34
|
+
}
|
|
35
|
+
}
|