@reactoo/watchtogether-sdk-js 2.7.31 → 2.7.32
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/package.json
CHANGED
package/src/modules/wt-iot.js
CHANGED
|
@@ -142,8 +142,10 @@ class Iot {
|
|
|
142
142
|
send(topic, message) {
|
|
143
143
|
this.log('iot send', topic, message);
|
|
144
144
|
let msg = typeof message === 'object' ? JSON.stringify(message) : message;
|
|
145
|
-
if (this.connection) {
|
|
145
|
+
if (this.connection && this.connection.currentState === 0 && this.connection.desiredState === 0) {
|
|
146
146
|
this.connection.publish(topic, msg, mqtt.QoS.AtLeastOnce, false);
|
|
147
|
+
} else {
|
|
148
|
+
throw new Error('Invalid topic or not connected:', topic);
|
|
147
149
|
}
|
|
148
150
|
}
|
|
149
151
|
|