@iobroker/socket-classes 1.3.1 → 1.3.3
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/README.md +16 -9
- package/lib/socketCommands.js +24 -6
- package/lib/socketCommandsAdmin.js +1 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,6 +122,7 @@ function sendImage(camera, data) {
|
|
|
122
122
|
* [authenticate](#authenticate_w)
|
|
123
123
|
* [error](#error_w)
|
|
124
124
|
* [log](#log_w)
|
|
125
|
+
* [checkFeatureSupported](#checkfeaturesupported_w)
|
|
125
126
|
* [getHistory](#gethistory_w)
|
|
126
127
|
* [httpGet](#httpget_w)
|
|
127
128
|
* [sendTo](#sendto_w)
|
|
@@ -183,6 +184,11 @@ Write log entry into ioBroker log
|
|
|
183
184
|
* text *(string)*: log text
|
|
184
185
|
* level *(string)*: one of `['silly', 'debug', 'info', 'warn', 'error']`. Default is 'debug'.
|
|
185
186
|
|
|
187
|
+
### <a name="checkfeaturesupported_w"></a>checkFeatureSupported(feature, callback)
|
|
188
|
+
Checks, if the same feature is supported by the current js-controller
|
|
189
|
+
* feature *(string)*: feature name like `CONTROLLER_LICENSE_MANAGER`
|
|
190
|
+
* callback *(function)*: `function (error, isSupported)`
|
|
191
|
+
|
|
186
192
|
### <a name="gethistory_w"></a>getHistory(id, options, callback)
|
|
187
193
|
Get history data from specific instance
|
|
188
194
|
* id *(string)*: object ID
|
|
@@ -456,6 +462,7 @@ Read all instances of the given adapter, or all instances of all adapters if ada
|
|
|
456
462
|
* [authenticate](#authenticate_a)
|
|
457
463
|
* [error](#error_a)
|
|
458
464
|
* [log](#log_a)
|
|
465
|
+
* [checkFeatureSupported](#checkfeaturesupported_a)
|
|
459
466
|
* [getHistory](#gethistory_a)
|
|
460
467
|
* [httpGet](#httpget_a)
|
|
461
468
|
* [sendTo](#sendto_a)
|
|
@@ -474,7 +481,6 @@ Read all instances of the given adapter, or all instances of all adapters if ada
|
|
|
474
481
|
* [eventsThreshold](#eventsthreshold_a)
|
|
475
482
|
* [getRatings](#getratings_a)
|
|
476
483
|
* [getCurrentInstance](#getcurrentinstance_a)
|
|
477
|
-
* [checkFeatureSupported](#checkfeaturesupported_a)
|
|
478
484
|
* [decrypt](#decrypt_a)
|
|
479
485
|
* [encrypt](#encrypt_a)
|
|
480
486
|
* [getIsEasyModeStrict](#getiseasymodestrict_a)
|
|
@@ -548,6 +554,11 @@ Write log entry into ioBroker log
|
|
|
548
554
|
* text *(string)*: log text
|
|
549
555
|
* level *(string)*: one of `['silly', 'debug', 'info', 'warn', 'error']`. Default is 'debug'.
|
|
550
556
|
|
|
557
|
+
### <a name="checkfeaturesupported_a"></a>checkFeatureSupported(feature, callback)
|
|
558
|
+
Checks, if the same feature is supported by the current js-controller
|
|
559
|
+
* feature *(string)*: feature name like `CONTROLLER_LICENSE_MANAGER`
|
|
560
|
+
* callback *(function)*: `function (error, isSupported)`
|
|
561
|
+
|
|
551
562
|
### <a name="gethistory_a"></a>getHistory(id, options, callback)
|
|
552
563
|
Get history data from specific instance
|
|
553
564
|
* id *(string)*: object ID
|
|
@@ -638,11 +649,6 @@ Read ratings of adapters
|
|
|
638
649
|
Return current instance name like `admin.0`
|
|
639
650
|
* callback *(function)*: `function (error, namespace)`
|
|
640
651
|
|
|
641
|
-
### <a name="checkfeaturesupported_a"></a>checkFeatureSupported(feature, callback)
|
|
642
|
-
Checks, if the same feature is supported by the current js-controller
|
|
643
|
-
* feature *(string)*: feature name like `CONTROLLER_LICENSE_MANAGER`
|
|
644
|
-
* callback *(function)*: `function (error, isSupported)`
|
|
645
|
-
|
|
646
652
|
### <a name="decrypt_a"></a>decrypt(encryptedText, callback)
|
|
647
653
|
Decrypts text with the system secret key
|
|
648
654
|
* encryptedText *(string)*: encrypted text
|
|
@@ -972,8 +978,9 @@ Read all instances of the given adapter, or all instances of all adapters if ada
|
|
|
972
978
|
-->
|
|
973
979
|
|
|
974
980
|
## Changelog
|
|
975
|
-
### 1.3.
|
|
981
|
+
### 1.3.3 (2023-08-01)
|
|
976
982
|
* (bluefox) Implemented subscribes of a client on messages from specific instance
|
|
983
|
+
* (bluefox) Moved checkFeatureSupported to regular connection and not only admin
|
|
977
984
|
|
|
978
985
|
### 1.2.0 (2023-07-07)
|
|
979
986
|
* (foxriver76) fixed crash on invalid patterns with js-controller version 5
|
|
@@ -1029,13 +1036,13 @@ Read all instances of the given adapter, or all instances of all adapters if ada
|
|
|
1029
1036
|
* (bluefox) Do not show error with failed authentication
|
|
1030
1037
|
|
|
1031
1038
|
### 0.4.7 (2022-06-20)
|
|
1032
|
-
* (bluefox) Allowed
|
|
1039
|
+
* (bluefox) Allowed overloading system language
|
|
1033
1040
|
|
|
1034
1041
|
### 0.4.6 (2022-06-20)
|
|
1035
1042
|
* (bluefox) updated `passport`
|
|
1036
1043
|
|
|
1037
1044
|
### 0.4.5 (2022-06-20)
|
|
1038
|
-
* (bluefox)
|
|
1045
|
+
* (bluefox) allowed running socket.io behind reverse proxy
|
|
1039
1046
|
|
|
1040
1047
|
### 0.4.4 (2022-06-09)
|
|
1041
1048
|
* (bluefox) Do not show requireLog message
|
package/lib/socketCommands.js
CHANGED
|
@@ -238,11 +238,11 @@ class SocketCommands {
|
|
|
238
238
|
) {
|
|
239
239
|
socket.emit('im', messageType, sourceInstance, data);
|
|
240
240
|
return true;
|
|
241
|
-
} else {
|
|
242
|
-
// inform instance about missing subscription
|
|
243
|
-
this.adapter.sendTo(sourceInstance, 'clientSubscribeError', {type: messageType, sid: socket.id});
|
|
244
|
-
return false;
|
|
245
241
|
}
|
|
242
|
+
|
|
243
|
+
// inform instance about missing subscription
|
|
244
|
+
this.adapter.sendTo(sourceInstance, 'clientSubscribeError', {type: messageType, sid: socket.id, reason: 'no one subscribed'});
|
|
245
|
+
return false;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
_showSubscribes(socket, type) {
|
|
@@ -663,6 +663,17 @@ class SocketCommands {
|
|
|
663
663
|
}
|
|
664
664
|
};
|
|
665
665
|
|
|
666
|
+
this.commands['checkFeatureSupported'] = (socket, feature, callback) => {
|
|
667
|
+
// Checks, if the same feature is supported by the current js-controller
|
|
668
|
+
// @param {string} feature - feature name like `CONTROLLER_LICENSE_MANAGER`
|
|
669
|
+
// @param {function} callback - `function (error, isSupported)`
|
|
670
|
+
if (feature === 'INSTANCE_MESSAGES') {
|
|
671
|
+
SocketCommands._fixCallback(callback, null, true);
|
|
672
|
+
} else {
|
|
673
|
+
SocketCommands._fixCallback(callback, null, this.adapter.supportsFeature && this.adapter.supportsFeature(feature));
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
|
|
666
677
|
// new History
|
|
667
678
|
this.commands['getHistory'] = (socket, id, options, callback) => {
|
|
668
679
|
// Get history data from specific instance
|
|
@@ -1593,6 +1604,9 @@ class SocketCommands {
|
|
|
1593
1604
|
callback = data;
|
|
1594
1605
|
data = null;
|
|
1595
1606
|
}
|
|
1607
|
+
if (!targetInstance.startsWith('system.adapter.')) {
|
|
1608
|
+
targetInstance = `system.adapter.${targetInstance}`;
|
|
1609
|
+
}
|
|
1596
1610
|
const sid = socket.id;
|
|
1597
1611
|
// GUI subscribes for messages from targetInstance
|
|
1598
1612
|
this.clientSubscribes[sid] = this.clientSubscribes[sid] || {};
|
|
@@ -1611,13 +1625,17 @@ class SocketCommands {
|
|
|
1611
1625
|
// @param {string} messageType - message type, e.g. "startRecording/cam1"
|
|
1612
1626
|
// @param {function} callback - `function (error, wasSubscribed)`, target instance MUST NOT acknowledge the un-subscription
|
|
1613
1627
|
const sid = socket.id;
|
|
1628
|
+
if (!targetInstance.startsWith('system.adapter.')) {
|
|
1629
|
+
targetInstance = `system.adapter.${targetInstance}`;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1614
1632
|
// GUI unsubscribes for messages from targetInstance
|
|
1615
1633
|
if (this.clientSubscribes[sid] && this.clientSubscribes[sid][targetInstance]) {
|
|
1616
1634
|
const pos = this.clientSubscribes[sid][targetInstance].indexOf(messageType);
|
|
1617
1635
|
if (pos !== -1) {
|
|
1618
1636
|
this.clientSubscribes[sid][targetInstance].splice(pos, 1);
|
|
1619
1637
|
// inform instance about unsubscription
|
|
1620
|
-
this.adapter.sendTo(targetInstance, 'clientUnsubscribe', {type: [messageType], sid});
|
|
1638
|
+
this.adapter.sendTo(targetInstance, 'clientUnsubscribe', {type: [messageType], sid, reason: 'client'});
|
|
1621
1639
|
SocketCommands._fixCallback(callback, null, true);
|
|
1622
1640
|
return;
|
|
1623
1641
|
}
|
|
@@ -1640,7 +1658,7 @@ class SocketCommands {
|
|
|
1640
1658
|
this.adapter.sendTo(targetInstance, 'clientUnsubscribe', {
|
|
1641
1659
|
message: this.clientSubscribes[socketId][targetInstance],
|
|
1642
1660
|
sid: socketId,
|
|
1643
|
-
|
|
1661
|
+
reason: 'disconnect',
|
|
1644
1662
|
});
|
|
1645
1663
|
});
|
|
1646
1664
|
delete this.clientSubscribes[socketId];
|
|
@@ -230,7 +230,7 @@ class SocketCommandsAdmin extends SocketCommands {
|
|
|
230
230
|
|
|
231
231
|
systemLicenses.native.readTime = new Date().toISOString();
|
|
232
232
|
|
|
233
|
-
// save only if object changed
|
|
233
|
+
// save only if an object changed
|
|
234
234
|
return this.adapter.setForeignObjectAsync('system.licenses', systemLicenses, options)
|
|
235
235
|
.then(() => licenses);
|
|
236
236
|
})
|
|
@@ -810,13 +810,6 @@ class SocketCommandsAdmin extends SocketCommands {
|
|
|
810
810
|
SocketCommands._fixCallback(callback, null, this.adapter.namespace);
|
|
811
811
|
};
|
|
812
812
|
|
|
813
|
-
this.commands['checkFeatureSupported'] = (socket, feature, callback) => {
|
|
814
|
-
// Checks, if the same feature is supported by the current js-controller
|
|
815
|
-
// @param {string} feature - feature name like `CONTROLLER_LICENSE_MANAGER`
|
|
816
|
-
// @param {function} callback - `function (error, isSupported)`
|
|
817
|
-
SocketCommands._fixCallback(callback, null, this.adapter.supportsFeature && this.adapter.supportsFeature(feature));
|
|
818
|
-
};
|
|
819
|
-
|
|
820
813
|
this.commands['decrypt'] = (socket, encryptedText, callback) => {
|
|
821
814
|
// Decrypts text with the system secret key
|
|
822
815
|
// @param {string} encryptedText - encrypted text
|