@mysetup/mqtt 1.2.0 → 1.3.0
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/mqttClient.d.ts +6 -7
- package/dist/mqttClient.d.ts.map +1 -1
- package/dist/mqttClient.js +8 -8
- package/package.json +1 -1
package/dist/mqttClient.d.ts
CHANGED
|
@@ -7,11 +7,10 @@ interface ConnectionProps {
|
|
|
7
7
|
topicList: string[];
|
|
8
8
|
messageCallback?: (topic: string, message: string) => void;
|
|
9
9
|
}
|
|
10
|
-
declare const mqttSub: (topicList: string[], messageCallback?: (topic: string, message: string) => void, client?: MqttClient) => void;
|
|
11
|
-
declare const mqttUnSub: (topicList: string[], client?: MqttClient) => void;
|
|
12
|
-
declare const mqttDisconnect: (props: ConnectionProps, reinit: boolean, client?: MqttClient) => void;
|
|
13
|
-
declare const mqttOnMessage: (messageCallback: (topic: string, message: string) => void, client?: MqttClient) => void;
|
|
14
|
-
declare const
|
|
15
|
-
declare const
|
|
16
|
-
export { mqttCreateConnection, mqttSub, mqttUnSub, mqttDisconnect, mqttOnMessage, getMqttClient, };
|
|
10
|
+
export declare const mqttSub: (topicList: string[], messageCallback?: (topic: string, message: string) => void, client?: MqttClient) => void;
|
|
11
|
+
export declare const mqttUnSub: (topicList: string[], client?: MqttClient) => void;
|
|
12
|
+
export declare const mqttDisconnect: (props: ConnectionProps, reinit: boolean, client?: MqttClient) => void;
|
|
13
|
+
export declare const mqttOnMessage: (messageCallback: (topic: string, message: string) => void, client?: MqttClient) => void;
|
|
14
|
+
export declare const getMqttClient: () => string;
|
|
15
|
+
export declare const mqttCreateConnection: (props: ConnectionProps) => MqttClient;
|
|
17
16
|
//# sourceMappingURL=mqttClient.d.ts.map
|
package/dist/mqttClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mqttClient.d.ts","sourceRoot":"","sources":["../mqttClient.ts"],"names":[],"mappings":"AAEA,OAAO,K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,UAAW,eAAe,eAE1D,CAAC"}
|
package/dist/mqttClient.js
CHANGED
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.getMqttClient = exports.mqttOnMessage = exports.mqttDisconnect = exports.mqttUnSub = exports.mqttSub =
|
|
14
|
+
exports.mqttCreateConnection = exports.getMqttClient = exports.mqttOnMessage = exports.mqttDisconnect = exports.mqttUnSub = exports.mqttSub = void 0;
|
|
15
15
|
var mqtt_1 = require("mqtt");
|
|
16
16
|
var logger_1 = require("@mysetup/logger");
|
|
17
17
|
var cache_1 = require("@mysetup/cache");
|
|
@@ -41,12 +41,12 @@ var checkInitConnect = function (props) {
|
|
|
41
41
|
client.on("connect", function () {
|
|
42
42
|
logger_1.logger.info("MQTT connection successful");
|
|
43
43
|
(0, cache_1.setCacheData)("mqttClientStatus", "connect");
|
|
44
|
-
mqttSub(props.topicList, props.messageCallback, client);
|
|
44
|
+
(0, exports.mqttSub)(props.topicList, props.messageCallback, client);
|
|
45
45
|
});
|
|
46
46
|
client.on("error", function (err) {
|
|
47
47
|
logger_1.logger.error("MQTT Connection error: ".concat(JSON.stringify(err)));
|
|
48
48
|
(0, cache_1.setCacheData)("mqttClientStatus", "error");
|
|
49
|
-
mqttDisconnect(props, true, client);
|
|
49
|
+
(0, exports.mqttDisconnect)(props, true, client);
|
|
50
50
|
});
|
|
51
51
|
client.on("reconnect", function () {
|
|
52
52
|
(0, cache_1.setCacheData)("mqttClientStatus", "reconnect");
|
|
@@ -74,7 +74,7 @@ var mqttSub = function (topicList, messageCallback, client) {
|
|
|
74
74
|
logger_1.logger.info("Subscribed to topics: ".concat(element.topic));
|
|
75
75
|
});
|
|
76
76
|
(0, cache_1.setCacheData)("subscribedTopic", grantedList);
|
|
77
|
-
messageCallback && mqttOnMessage(messageCallback, client);
|
|
77
|
+
messageCallback && (0, exports.mqttOnMessage)(messageCallback, client);
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
catch (error) {
|
|
@@ -139,11 +139,11 @@ var memoizedDb = function () {
|
|
|
139
139
|
};
|
|
140
140
|
// returned function from memoizedDb
|
|
141
141
|
var cachedConnection = memoizedDb();
|
|
142
|
-
var mqttCreateConnection = function (props) {
|
|
143
|
-
return cachedConnection(props);
|
|
144
|
-
};
|
|
145
|
-
exports.mqttCreateConnection = mqttCreateConnection;
|
|
146
142
|
var getMqttClient = function () {
|
|
147
143
|
return mqttClientId;
|
|
148
144
|
};
|
|
149
145
|
exports.getMqttClient = getMqttClient;
|
|
146
|
+
var mqttCreateConnection = function (props) {
|
|
147
|
+
return cachedConnection(props);
|
|
148
|
+
};
|
|
149
|
+
exports.mqttCreateConnection = mqttCreateConnection;
|