@iobroker/socket-classes 1.1.4 → 1.2.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/README.md CHANGED
@@ -140,22 +140,22 @@ Read content of HTTP(S) page server-side (without CORS and stuff)
140
140
  * callback *(function)*: `function (error, {status, statusText}, body)`
141
141
 
142
142
  ### <a name="sendto_w"></a>sendTo(adapterInstance, command, message, callback)
143
- Send message to specific instance
143
+ Send the message to specific instance
144
144
  * adapterInstance *(string)*: instance name, e.g. `history.0`
145
145
  * command *(string)*: command name
146
- * message *(object)*: message is instance dependent
146
+ * message *(object)*: the message is instance dependent
147
147
  * callback *(function)*: `function (result)`
148
148
 
149
149
  ### <a name="sendtohost_w"></a>sendToHost(host, command, message, callback)
150
- Send message to specific host.
151
- Host can answer following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
150
+ Send a message to the specific host.
151
+ Host can answer to the following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
152
152
  * host *(string)*: instance name, e.g. `history.0`
153
153
  * command *(string)*: command name
154
- * message *(object)*: message is command specific
154
+ * message *(object)*: the message is command-specific
155
155
  * callback *(function)*: `function (result)`
156
156
 
157
157
  ### <a name="authenabled_w"></a>authEnabled(callback)
158
- Ask server is authentication enabled and if the user authenticated
158
+ Ask server is authentication enabled, and if the user authenticated
159
159
  * callback *(function)*: `function (isAuthenticationUsed, userName)`
160
160
 
161
161
  ### <a name="logout_w"></a>logout(callback)
@@ -171,7 +171,7 @@ Get user permissions
171
171
  * callback *(function)*: `function (error, permissions)`
172
172
 
173
173
  ### <a name="getversion_w"></a>getVersion(callback)
174
- Get adapter version. Not the socket-classes version!
174
+ Get the adapter version. Not the socket-classes version!
175
175
  * callback *(function)*: `function (error, adapterVersion, adapterName)`
176
176
 
177
177
  ### <a name="getadaptername_w"></a>getAdapterName(callback)
@@ -183,18 +183,19 @@ Get one object
183
183
  * id *(string)*: object ID.
184
184
  * callback *(function)*: `function (error, obj)`
185
185
 
186
- ### <a name="getobjects_w"></a>getObjects(callback)
186
+ ### <a name="getobjects_w"></a>getObjects(list, callback)
187
187
  Get all objects that are relevant for web: all states and enums with rooms
188
188
  * id *(string)*: object ID.
189
+ * list *(string[])*: optional list of IDs.
189
190
  * callback *(function)*: `function (error, obj)`
190
191
 
191
192
  ### <a name="subscribeobjects_w"></a>subscribeObjects(pattern, callback)
192
- Subscribe on object changes by pattern. The events will come as 'objectChange' events to the socket.
193
+ Subscribe to object changes by pattern. The events will come as 'objectChange' events to the socket.
193
194
  * pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
194
195
  * callback *(function)*: `function (error)`
195
196
 
196
197
  ### <a name="unsubscribeobjects_w"></a>unsubscribeObjects(pattern, callback)
197
- Unsubscribe on object changes by pattern.
198
+ Unsubscribe from object changes by pattern.
198
199
  * pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
199
200
  * callback *(function)*: `function (error)`
200
201
 
@@ -224,7 +225,7 @@ Read states by pattern
224
225
 
225
226
  ### <a name="getforeignstates_w"></a>getForeignStates(pattern, callback)
226
227
  Read all states (which might not belong to this adapter) which match the given pattern
227
- * pattern *(string)*: pattern like
228
+ * pattern *(string)*: pattern like `system.adapter.*` or array of state IDs
228
229
  * callback *(function)*: `function (error)`
229
230
 
230
231
  ### <a name="getstate_w"></a>getState(id, callback)
@@ -246,16 +247,16 @@ Read one binary state.
246
247
  ### <a name="setbinarystate_w"></a>setBinaryState(id, base64, callback)
247
248
  Write one binary state.
248
249
  * id *(string)*: State ID like, 'javascript.0.binary'
249
- * base64 *(string)*: State value as base64 string. Binary states has no acknowledge flag.
250
+ * base64 *(string)*: State value as base64 string. Binary states have no acknowledged flag.
250
251
  * callback *(function)*: `function (error)`
251
252
 
252
253
  ### <a name="subscribe_w"></a>subscribe(pattern, callback)
253
- Subscribe on state changes by pattern. The events will come as 'stateChange' events to the socket.
254
+ Subscribe to state changes by pattern. The events will come as 'stateChange' events to the socket.
254
255
  * pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
255
256
  * callback *(function)*: `function (error)`
256
257
 
257
258
  ### <a name="subscribestates_w"></a>subscribeStates(pattern, callback)
258
- Subscribe on state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
259
+ Subscribe to state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
259
260
  * pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
260
261
  * callback *(function)*: `function (error)`
261
262
 
@@ -346,7 +347,7 @@ Read content of folder in ioBroker DB
346
347
  Change file mode in ioBroker DB
347
348
  * _adapter *(string)*: instance name, e.g. `vis.0`
348
349
  * fileName *(string)*: file name, e.g `main/vis-views.json`
349
- * options *(object)*: `{mode: 0x644}` or 0x644. First digit is user, second group, third others. Bit 1 is `execute`, bit 2 is `write`, bit 3 is `read`
350
+ * options *(object)*: `{mode: 0x644}` or 0x644. The first digit is user, second group, third others. Bit 1 is `execute`, bit 2 is `write`, bit 3 is `read`
350
351
  * callback *(function)*: `function (error)`
351
352
 
352
353
  ### <a name="chownfile_w"></a>chownFile(_adapter, fileName, options, callback)
@@ -357,19 +358,19 @@ Change file owner in ioBroker DB
357
358
  * callback *(function)*: `function (error)`
358
359
 
359
360
  ### <a name="fileexists_w"></a>fileExists(_adapter, fileName, callback)
360
- Checks if the file or folder exists in ioBroker DB
361
+ Check if the file or folder exists in ioBroker DB
361
362
  * _adapter *(string)*: instance name, e.g. `vis.0`
362
363
  * fileName *(string)*: file name, e.g `main/vis-views.json`
363
364
  * callback *(function)*: `function (error, isExist)`
364
365
 
365
366
  ### <a name="subscribefiles_w"></a>subscribeFiles(id, pattern, callback)
366
- Subscribe on file changes in ioBroker DB
367
+ Subscribe to file changes in ioBroker DB
367
368
  * id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
368
369
  * pattern *(string)*: file name pattern, e.g `main/*.json`
369
370
  * callback *(function)*: `function (error)`
370
371
 
371
372
  ### <a name="unsubscribefiles_w"></a>unsubscribeFiles(id, pattern, callback)
372
- Unsubscribe on file changes in ioBroker DB
373
+ Unsubscribe from file changes in ioBroker DB
373
374
  * id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
374
375
  * pattern *(string)*: file name pattern, e.g `main/*.json`
375
376
  * callback *(function)*: `function (error)`
@@ -489,22 +490,22 @@ Read content of HTTP(S) page server-side (without CORS and stuff)
489
490
  * callback *(function)*: `function (error, {status, statusText}, body)`
490
491
 
491
492
  ### <a name="sendto_a"></a>sendTo(adapterInstance, command, message, callback)
492
- Send message to specific instance
493
+ Send the message to specific instance
493
494
  * adapterInstance *(string)*: instance name, e.g. `history.0`
494
495
  * command *(string)*: command name
495
- * message *(object)*: message is instance dependent
496
+ * message *(object)*: the message is instance dependent
496
497
  * callback *(function)*: `function (result)`
497
498
 
498
499
  ### <a name="sendtohost_a"></a>sendToHost(host, command, message, callback)
499
- Send message to specific host.
500
- Host can answer following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
500
+ Send a message to the specific host.
501
+ Host can answer to the following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
501
502
  * host *(string)*: instance name, e.g. `history.0`
502
503
  * command *(string)*: command name
503
- * message *(object)*: message is command specific
504
+ * message *(object)*: the message is command-specific
504
505
  * callback *(function)*: `function (result)`
505
506
 
506
507
  ### <a name="authenabled_a"></a>authEnabled(callback)
507
- Ask server is authentication enabled and if the user authenticated
508
+ Ask server is authentication enabled, and if the user authenticated
508
509
  * callback *(function)*: `function (isAuthenticationUsed, userName)`
509
510
 
510
511
  ### <a name="logout_a"></a>logout(callback)
@@ -520,7 +521,7 @@ Get user permissions
520
521
  * callback *(function)*: `function (error, permissions)`
521
522
 
522
523
  ### <a name="getversion_a"></a>getVersion(callback)
523
- Get adapter version. Not the socket-classes version!
524
+ Get the adapter version. Not the socket-classes version!
524
525
  * callback *(function)*: `function (error, adapterVersion, adapterName)`
525
526
 
526
527
  ### <a name="getadaptername_a"></a>getAdapterName(callback)
@@ -528,9 +529,9 @@ Get adapter name. Not the socket-classes version!
528
529
  * callback *(function)*: `function (error, adapterVersion)`
529
530
 
530
531
  ### <a name="gethostbyip_a"></a>getHostByIp(ip, callback)
531
- Read host object by IP address
532
+ Read the host object by IP address
532
533
  * ip *(string)*: ip address. IPv4 or IPv6
533
- * callback *(function)*: `function (ip, obj)`. If host not found, obj is null
534
+ * callback *(function)*: `function (ip, obj)`. If host is not found, obj is null
534
535
 
535
536
  ### <a name="requirelog_a"></a>requireLog(isEnabled, callback)
536
537
  Activate or deactivate logging events. Events will be sent to the socket as `log` event. Adapter must have `common.logTransporter = true`
@@ -543,19 +544,19 @@ Get logs file from given host
543
544
  * callback *(function)*: `function (error, files)`, where `files` is array of `{fileName: `log/hostname/transport/file`, size: 123}`
544
545
 
545
546
  ### <a name="delstate_a"></a>delState(id, callback)
546
- Delete state. Corresponding object will be deleted too.
547
+ Delete state. The corresponding object will be deleted too.
547
548
  * id *(string)*: state ID
548
549
  * callback *(function)*: `function (error)`
549
550
 
550
551
  ### <a name="cmdexec_a"></a>cmdExec(host, id, cmd, callback)
551
- Execute shell command on host/controller. Following response commands are expected: ´cmdStdout, cmdStderr, cmdExit´
552
+ Execute the shell command on host/controller. Following response commands are expected: ´cmdStdout, cmdStderr, cmdExit´
552
553
  * host *(string)*: host name, like 'system.host.raspberrypi'
553
554
  * id *(string)*: session ID, like `Date.now()´. This session ID will come in events `cmdStdout, cmdStderr, cmdExit`
554
555
  * cmd *(string)*: command
555
556
  * callback *(function)*: `function (error)`
556
557
 
557
558
  ### <a name="eventsthreshold_a"></a>eventsThreshold(isActive)
558
- Used only for admin to limit number of events to front-end.
559
+ Used only for admin to the limited number of events to front-end.
559
560
  * isActive *(boolean)*: if true, then events will be limited
560
561
 
561
562
  ### <a name="getratings_a"></a>getRatings(update, callback)
@@ -568,17 +569,17 @@ Return current instance name like `admin.0`
568
569
  * callback *(function)*: `function (error, namespace)`
569
570
 
570
571
  ### <a name="checkfeaturesupported_a"></a>checkFeatureSupported(feature, callback)
571
- Checks if same feature is supported by current js-controller
572
+ Checks, if the same feature is supported by the current js-controller
572
573
  * feature *(string)*: feature name like `CONTROLLER_LICENSE_MANAGER`
573
574
  * callback *(function)*: `function (error, isSupported)`
574
575
 
575
576
  ### <a name="decrypt_a"></a>decrypt(encryptedText, callback)
576
- Decrypts text with system secret key
577
+ Decrypts text with the system secret key
577
578
  * encryptedText *(string)*: encrypted text
578
579
  * callback *(function)*: `function (error, decryptedText)`
579
580
 
580
581
  ### <a name="encrypt_a"></a>encrypt(plainText, callback)
581
- Encrypts text with system secret key
582
+ Encrypts text with the system secret key
582
583
  * plainText *(string)*: normal text
583
584
  * callback *(function)*: `function (error, encryptedText)`
584
585
 
@@ -641,14 +642,14 @@ Delete existing user. Admin cannot be deleted.
641
642
  * callback *(function)*: `function (error)`
642
643
 
643
644
  ### <a name="addgroup_a"></a>addGroup(group, desc, acl, callback)
644
- Add new group.
645
+ Add a new group.
645
646
  * group *(string)*: user name, like 'benjamin
646
647
  * desc *(string)*: optional description
647
648
  * acl *(object)*: optional access control list object, like `{"object":{"list":true,"read":true,"write":false,"delete":false},"state":{"list":true,"read":true,"write":true,"create":true,"delete":false},"users":{"list":true,"read":true,"write":false,"create":false,"delete":false},"other":{"execute":false,"http":true,"sendto":false},"file":{"list":true,"read":true,"write":false,"create":false,"delete":false}}`
648
649
  * callback *(function)*: `function (error)`
649
650
 
650
651
  ### <a name="delgroup_a"></a>delGroup(group, callback)
651
- Delete existing group. Administrator group cannot be deleted.
652
+ Delete the existing group. Administrator group cannot be deleted.
652
653
  * group *(string)*: group name, like 'users`
653
654
  * callback *(function)*: `function (error)`
654
655
 
@@ -668,12 +669,12 @@ Read absolutely all objects. Same as `getAllObjects`.
668
669
  * callback *(function)*: `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
669
670
 
670
671
  ### <a name="subscribeobjects_a"></a>subscribeObjects(pattern, callback)
671
- Subscribe on object changes by pattern. The events will come as 'objectChange' events to the socket.
672
+ Subscribe to object changes by pattern. The events will come as 'objectChange' events to the socket.
672
673
  * pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
673
674
  * callback *(function)*: `function (error)`
674
675
 
675
676
  ### <a name="unsubscribeobjects_a"></a>unsubscribeObjects(pattern, callback)
676
- Unsubscribe on object changes by pattern.
677
+ Unsubscribe from object changes by pattern.
677
678
  * pattern *(string)*: pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
678
679
  * callback *(function)*: `function (error)`
679
680
 
@@ -691,7 +692,7 @@ Set object.
691
692
  * callback *(function)*: `function (error)`
692
693
 
693
694
  ### <a name="delobject_a"></a>delObject(id, options, callback)
694
- Delete object or objects recursively. Objects with `dontDelete` cannot be deleted.
695
+ Delete an object or objects recursively. Objects with `dontDelete` cannot be deleted.
695
696
  * id *(string)*: Object ID like, 'adapterName.0.channel'
696
697
  * options *(string)*: `{recursive: true}`
697
698
  * callback *(function)*: `function (error)`
@@ -701,7 +702,7 @@ Read absolutely all objects
701
702
  * callback *(function)*: `function (error, objects)`, where `objects` is an object like `{'system.adapter.admin.0': {...}, 'system.adapter.web.0': {...}}`
702
703
 
703
704
  ### <a name="extendobject_a"></a>extendObject(id, obj, callback)
704
- Extend existing object
705
+ Extend the existing object
705
706
  * id *(string)*: object ID
706
707
  * obj *(object)*: new parts of the object, like `{common: {name: 'new name'}}`
707
708
  * callback *(function)*: `function (error)`
@@ -725,7 +726,7 @@ Read states by pattern
725
726
 
726
727
  ### <a name="getforeignstates_a"></a>getForeignStates(pattern, callback)
727
728
  Read all states (which might not belong to this adapter) which match the given pattern
728
- * pattern *(string)*: pattern like
729
+ * pattern *(string)*: pattern like `system.adapter.*` or array of state IDs
729
730
  * callback *(function)*: `function (error)`
730
731
 
731
732
  ### <a name="getstate_a"></a>getState(id, callback)
@@ -747,16 +748,16 @@ Read one binary state.
747
748
  ### <a name="setbinarystate_a"></a>setBinaryState(id, base64, callback)
748
749
  Write one binary state.
749
750
  * id *(string)*: State ID like, 'javascript.0.binary'
750
- * base64 *(string)*: State value as base64 string. Binary states has no acknowledge flag.
751
+ * base64 *(string)*: State value as base64 string. Binary states have no acknowledged flag.
751
752
  * callback *(function)*: `function (error)`
752
753
 
753
754
  ### <a name="subscribe_a"></a>subscribe(pattern, callback)
754
- Subscribe on state changes by pattern. The events will come as 'stateChange' events to the socket.
755
+ Subscribe to state changes by pattern. The events will come as 'stateChange' events to the socket.
755
756
  * pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
756
757
  * callback *(function)*: `function (error)`
757
758
 
758
759
  ### <a name="subscribestates_a"></a>subscribeStates(pattern, callback)
759
- Subscribe on state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
760
+ Subscribe to state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
760
761
  * pattern *(string)*: pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
761
762
  * callback *(function)*: `function (error)`
762
763
 
@@ -847,7 +848,7 @@ Read content of folder in ioBroker DB
847
848
  Change file mode in ioBroker DB
848
849
  * _adapter *(string)*: instance name, e.g. `vis.0`
849
850
  * fileName *(string)*: file name, e.g `main/vis-views.json`
850
- * options *(object)*: `{mode: 0x644}` or 0x644. First digit is user, second group, third others. Bit 1 is `execute`, bit 2 is `write`, bit 3 is `read`
851
+ * options *(object)*: `{mode: 0x644}` or 0x644. The first digit is user, second group, third others. Bit 1 is `execute`, bit 2 is `write`, bit 3 is `read`
851
852
  * callback *(function)*: `function (error)`
852
853
 
853
854
  ### <a name="chownfile_a"></a>chownFile(_adapter, fileName, options, callback)
@@ -858,19 +859,19 @@ Change file owner in ioBroker DB
858
859
  * callback *(function)*: `function (error)`
859
860
 
860
861
  ### <a name="fileexists_a"></a>fileExists(_adapter, fileName, callback)
861
- Checks if the file or folder exists in ioBroker DB
862
+ Check if the file or folder exists in ioBroker DB
862
863
  * _adapter *(string)*: instance name, e.g. `vis.0`
863
864
  * fileName *(string)*: file name, e.g `main/vis-views.json`
864
865
  * callback *(function)*: `function (error, isExist)`
865
866
 
866
867
  ### <a name="subscribefiles_a"></a>subscribeFiles(id, pattern, callback)
867
- Subscribe on file changes in ioBroker DB
868
+ Subscribe to file changes in ioBroker DB
868
869
  * id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
869
870
  * pattern *(string)*: file name pattern, e.g `main/*.json`
870
871
  * callback *(function)*: `function (error)`
871
872
 
872
873
  ### <a name="unsubscribefiles_a"></a>unsubscribeFiles(id, pattern, callback)
873
- Unsubscribe on file changes in ioBroker DB
874
+ Unsubscribe from file changes in ioBroker DB
874
875
  * id *(string)*: instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
875
876
  * pattern *(string)*: file name pattern, e.g `main/*.json`
876
877
  * callback *(function)*: `function (error)`
@@ -888,7 +889,11 @@ Read all instances of the given adapter, or all instances of all adapters if ada
888
889
  -->
889
890
 
890
891
  ## Changelog
891
- ### 1.1.4 (2023-03-13)
892
+ ### 1.2.0 (2023-07-07)
893
+ * (foxriver76) fixed crash on invalid patterns with js-controller version 5
894
+ * (bluefox) extended the getObjects function with the possibility to read the list of IDs
895
+
896
+ ### 1.1.5 (2023-03-13)
892
897
  * (bluefox) Added command `name`
893
898
 
894
899
  ### 1.1.3 (2023-03-12)
@@ -264,7 +264,13 @@ class SocketCommands {
264
264
  key = pattern;
265
265
  }
266
266
 
267
- p = pattern2RegEx(key);
267
+ try {
268
+ p = pattern2RegEx(key);
269
+ } catch (e) {
270
+ this.adapter.log.error(`Invalid pattern on subscribe: ${e.message}`)
271
+ return
272
+ }
273
+
268
274
  if (p === null) {
269
275
  return this.adapter.log.warn('Empty pattern on subscribe!');
270
276
  }
@@ -293,8 +299,8 @@ class SocketCommands {
293
299
  this.logEnabled = true;
294
300
  this.adapter.requireLog(true, options);
295
301
  }
296
- } else if (type === 'fileChange') {
297
- this.adapter.subscribeForeignFiles && this.adapter.subscribeForeignFiles(pattern, patternFile, options);
302
+ } else if (type === 'fileChange' && this.adapter.subscribeForeignFiles) {
303
+ this.adapter.subscribeForeignFiles(pattern, patternFile, options);
298
304
  }
299
305
  } else {
300
306
  this.subscribes[type][key]++;
@@ -689,10 +695,10 @@ class SocketCommands {
689
695
 
690
696
  // commands
691
697
  this.commands['sendTo'] = (socket, adapterInstance, command, message, callback) => {
692
- // Send message to specific instance
698
+ // Send the message to specific instance
693
699
  // @param {string} adapterInstance - instance name, e.g. `history.0`
694
700
  // @param {string} command - command name
695
- // @param {object} message - message is instance dependent
701
+ // @param {object} message - the message is instance dependent
696
702
  // @param {function} callback - `function (result)`
697
703
  if (this._checkPermissions(socket, 'sendTo', callback, command)) {
698
704
  try {
@@ -709,11 +715,11 @@ class SocketCommands {
709
715
  const protectedCommands = ['cmdExec', 'getLocationOnDisk', 'getDiagData', 'getDevList', 'delLogs', 'writeDirAsZip', 'writeObjectsAsZip', 'readObjectsAsZip', 'checkLogging', 'updateMultihost', 'rebuildAdapter'];
710
716
 
711
717
  this.commands['sendToHost'] = (socket, host, command, message, callback) => {
712
- // Send message to specific host.
713
- // Host can answer following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
718
+ // Send a message to the specific host.
719
+ // Host can answer to the following commands: `cmdExec, getRepository, getInstalled, getInstalledAdapter, getVersion, getDiagData, getLocationOnDisk, getDevList, getLogs, getHostInfo, delLogs, readDirAsZip, writeDirAsZip, readObjectsAsZip, writeObjectsAsZip, checkLogging, updateMultihost`.
714
720
  // @param {string} host - instance name, e.g. `history.0`
715
721
  // @param {string} command - command name
716
- // @param {object} message - message is command specific
722
+ // @param {object} message - the message is command-specific
717
723
  // @param {function} callback - `function (result)`
718
724
  if (this._checkPermissions(socket, protectedCommands.includes(command) ? 'cmdExec' : 'sendToHost', callback, command)) {
719
725
  // Try to decode this file locally as redis has a limitation for files bigger than 20MB
@@ -731,7 +737,7 @@ class SocketCommands {
731
737
  zipFiles
732
738
  .writeDirAsZip(
733
739
  this.adapter, // normally we have to pass here the internal "objects" object, but as
734
- // only writeFile is used, and it has the same name we can pass here the
740
+ // only writeFile is used, and it has the same name, we can pass here the
735
741
  // adapter, which has the function with the same name and arguments
736
742
  message.id,
737
743
  message.name,
@@ -757,7 +763,7 @@ class SocketCommands {
757
763
  };
758
764
 
759
765
  this.commands['authEnabled'] = (socket, callback) => {
760
- // Ask server is authentication enabled and if the user authenticated
766
+ // Ask server is authentication enabled, and if the user authenticated
761
767
  // @param {function} callback - `function (isAuthenticationUsed, userName)`
762
768
  if (this._checkPermissions(socket, 'authEnabled', callback)) {
763
769
  if (typeof callback === 'function') {
@@ -797,7 +803,7 @@ class SocketCommands {
797
803
  };
798
804
 
799
805
  this.commands['getVersion'] = (socket, callback) => {
800
- // Get adapter version. Not the socket-classes version!
806
+ // Get the adapter version. Not the socket-classes version!
801
807
  // @param {function} callback - `function (error, adapterVersion, adapterName)`
802
808
  if (this._checkPermissions(socket, 'getVersion', callback)) {
803
809
  if (typeof callback === 'function') {
@@ -1070,7 +1076,7 @@ class SocketCommands {
1070
1076
  // Change file mode in ioBroker DB
1071
1077
  // @param {string} _adapter - instance name, e.g. `vis.0`
1072
1078
  // @param {string} fileName - file name, e.g `main/vis-views.json`
1073
- // @param {object} options - `{mode: 0x644}` or 0x644. First digit is user, second group, third others. Bit 1 is `execute`, bit 2 is `write`, bit 3 is `read`
1079
+ // @param {object} options - `{mode: 0x644}` or 0x644. The first digit is user, second group, third others. Bit 1 is `execute`, bit 2 is `write`, bit 3 is `read`
1074
1080
  // @param {function} callback - `function (error)`
1075
1081
  if (typeof options === 'function') {
1076
1082
  callback = options;
@@ -1114,7 +1120,7 @@ class SocketCommands {
1114
1120
  };
1115
1121
 
1116
1122
  this.commands['fileExists'] = (socket, _adapter, fileName, callback) => {
1117
- // Checks if the file or folder exists in ioBroker DB
1123
+ // Check if the file or folder exists in ioBroker DB
1118
1124
  // @param {string} _adapter - instance name, e.g. `vis.0`
1119
1125
  // @param {string} fileName - file name, e.g `main/vis-views.json`
1120
1126
  // @param {function} callback - `function (error, isExist)`
@@ -1130,7 +1136,7 @@ class SocketCommands {
1130
1136
  };
1131
1137
 
1132
1138
  this.commands['subscribeFiles'] = (socket, id, pattern, callback) => {
1133
- // Subscribe on file changes in ioBroker DB
1139
+ // Subscribe to file changes in ioBroker DB
1134
1140
  // @param {string} id - instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
1135
1141
  // @param {string} pattern - file name pattern, e.g `main/*.json`
1136
1142
  // @param {function} callback - `function (error)`
@@ -1138,7 +1144,7 @@ class SocketCommands {
1138
1144
  }
1139
1145
 
1140
1146
  this.commands['unsubscribeFiles'] = (socket, id, pattern, callback) => {
1141
- // Unsubscribe on file changes in ioBroker DB
1147
+ // Unsubscribe from file changes in ioBroker DB
1142
1148
  // @param {string} id - instance name, e.g. `vis.0` or any object ID of type `meta`. `id` could have wildcards `*` too.
1143
1149
  // @param {string} pattern - file name pattern, e.g `main/*.json`
1144
1150
  // @param {function} callback - `function (error)`
@@ -1212,7 +1218,7 @@ class SocketCommands {
1212
1218
 
1213
1219
  this.commands['getForeignStates'] = (socket, pattern, callback) => {
1214
1220
  // Read all states (which might not belong to this adapter) which match the given pattern
1215
- // @param {string} pattern - pattern like
1221
+ // @param {string} pattern - pattern like `system.adapter.*` or array of state IDs
1216
1222
  // @param {function} callback - `function (error)`
1217
1223
  if (this._checkPermissions(socket, 'getStates', callback)) {
1218
1224
  if (typeof callback === 'function') {
@@ -1320,7 +1326,7 @@ class SocketCommands {
1320
1326
  this.commands['setBinaryState'] = (socket, id, base64, callback) => {
1321
1327
  // Write one binary state.
1322
1328
  // @param {string} id - State ID like, 'javascript.0.binary'
1323
- // @param {string} base64 - State value as base64 string. Binary states has no acknowledge flag.
1329
+ // @param {string} base64 - State value as base64 string. Binary states have no acknowledged flag.
1324
1330
  // @param {function} callback - `function (error)`
1325
1331
  if (this._checkPermissions(socket, 'setState', callback, id)) {
1326
1332
  if (typeof callback === 'function') {
@@ -1350,14 +1356,14 @@ class SocketCommands {
1350
1356
  };
1351
1357
 
1352
1358
  this.commands['subscribe'] = (socket, pattern, callback) => {
1353
- // Subscribe on state changes by pattern. The events will come as 'stateChange' events to the socket.
1359
+ // Subscribe to state changes by pattern. The events will come as 'stateChange' events to the socket.
1354
1360
  // @param {string} pattern - pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
1355
1361
  // @param {function} callback - `function (error)`
1356
1362
  return this._subscribeStates(socket, pattern, callback);
1357
1363
  };
1358
1364
 
1359
1365
  this.commands['subscribeStates'] = (socket, pattern, callback) => {
1360
- // Subscribe on state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
1366
+ // Subscribe to state changes by pattern. Same as `subscribe`. The events will come as 'stateChange' events to the socket.
1361
1367
  // @param {string} pattern - pattern like 'system.adapter.*' or array of states like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
1362
1368
  // @param {function} callback - `function (error)`
1363
1369
  return this._subscribeStates(socket, pattern, callback);
@@ -1401,11 +1407,30 @@ class SocketCommands {
1401
1407
 
1402
1408
  // not admin version of "all objects"
1403
1409
  // this function is overloaded in admin
1404
- this.commands['getObjects'] = (socket, callback) => {
1410
+ this.commands['getObjects'] = (socket, list, callback) => {
1405
1411
  // Get all objects that are relevant for web: all states and enums with rooms
1406
1412
  // @param {string} id - object ID.
1413
+ // @param {string[]} list - optional list of IDs.
1407
1414
  // @param {function} callback - `function (error, obj)`
1408
- if (this._checkPermissions(socket, 'getObjects', callback)) {
1415
+ if (typeof list === 'function') {
1416
+ callback = list;
1417
+ list = null;
1418
+ }
1419
+ if (list && list.length) {
1420
+ if (this._checkPermissions(socket, 'getObject', callback)) {
1421
+ if (typeof callback === 'function') {
1422
+ try {
1423
+ this.adapter.getForeignObjects(list, {user: socket._acl.user}, (error, objs) =>
1424
+ SocketCommands._fixCallback(callback, error, objs));
1425
+ } catch (error) {
1426
+ this.adapter.log.error(`[getObjects] ERROR: ${error.toString()}`);
1427
+ SocketCommands._fixCallback(callback, error);
1428
+ }
1429
+ } else {
1430
+ this.adapter.log.warn('[getObjects] Invalid callback');
1431
+ }
1432
+ }
1433
+ } else if (this._checkPermissions(socket, 'getObjects', callback)) {
1409
1434
  try {
1410
1435
  if (typeof callback === 'function') {
1411
1436
  this.adapter.getForeignObjects('*', 'state', 'rooms', {user: socket._acl.user}, async (error, objs) => {
@@ -1437,7 +1462,7 @@ class SocketCommands {
1437
1462
  };
1438
1463
 
1439
1464
  this.commands['subscribeObjects'] = (socket, pattern, callback) => {
1440
- // Subscribe on object changes by pattern. The events will come as 'objectChange' events to the socket.
1465
+ // Subscribe to object changes by pattern. The events will come as 'objectChange' events to the socket.
1441
1466
  // @param {string} pattern - pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
1442
1467
  // @param {function} callback - `function (error)`
1443
1468
  if (this._checkPermissions(socket, 'subscribeObjects', callback, pattern)) {
@@ -1461,7 +1486,7 @@ class SocketCommands {
1461
1486
  };
1462
1487
 
1463
1488
  this.commands['unsubscribeObjects'] = (socket, pattern, callback) => {
1464
- // Unsubscribe on object changes by pattern.
1489
+ // Unsubscribe from object changes by pattern.
1465
1490
  // @param {string} pattern - pattern like 'system.adapter.*' or array of IDs like ['system.adapter.admin.0.memRss', 'system.adapter.admin.0.memHeapTotal']
1466
1491
  // @param {function} callback - `function (error)`
1467
1492
  if (this._checkPermissions(socket, 'unsubscribeObjects', callback, pattern)) {
@@ -70,7 +70,7 @@ class SocketCommandsAdmin extends SocketCommands {
70
70
  }
71
71
 
72
72
  try {
73
- const response = await axios.get('https://rating.iobroker.net/rating?uuid=' + uuid, {timeout: 15000, validateStatus: status => status < 400})
73
+ const response = await axios.get(`https://rating.iobroker.net/rating?uuid=${uuid}`, {timeout: 15000, validateStatus: status => status < 400})
74
74
  this.adapter._ratings = response.data;
75
75
  if (!this.adapter._ratings || typeof this.adapter._ratings !== 'object' || Array.isArray(this.adapter._ratings)) {
76
76
  this.adapter._ratings = {};
@@ -95,7 +95,7 @@ class SocketCommandsAdmin extends SocketCommands {
95
95
 
96
96
  _readInstanceConfig(id, user, isTab, configs) {
97
97
  return new Promise(resolve =>
98
- this.adapter.getForeignObject('system.adapter.' + id, {user}, (error, obj) => {
98
+ this.adapter.getForeignObject(`system.adapter.${id}`, {user}, (error, obj) => {
99
99
  if (obj && obj.common) {
100
100
  const instance = id.split('.').pop();
101
101
  const config = {
@@ -103,7 +103,7 @@ class SocketCommandsAdmin extends SocketCommands {
103
103
  title: obj.common.titleLang || obj.common.title,
104
104
  desc: obj.common.desc,
105
105
  color: obj.common.color,
106
- url: `/adapter/${obj.common.name}/${isTab ? 'tab' : 'index'}${!isTab && obj.common.materialize ? '_m' : ''}.html${instance ? '?' + instance : ''}`,
106
+ url: `/adapter/${obj.common.name}/${isTab ? 'tab' : 'index'}${!isTab && obj.common.materialize ? '_m' : ''}.html${instance ? `?${instance}` : ''}`,
107
107
  icon: obj.common.icon,
108
108
  materialize: obj.common.materialize,
109
109
  jsonConfig: obj.common.jsonConfig,
@@ -157,7 +157,7 @@ class SocketCommandsAdmin extends SocketCommands {
157
157
  typeof callback === 'function' && setImmediate(() => callback(res));
158
158
  });
159
159
  } catch (error) {
160
- this.adapter.log.error('[sendToHost] ERROR: ' + error.toString());
160
+ this.adapter.log.error(`[sendToHost] ERROR: ${error.toString()}`);
161
161
  typeof callback === 'function' && setImmediate(() => callback({ error }));
162
162
  }
163
163
  }
@@ -275,7 +275,7 @@ class SocketCommandsAdmin extends SocketCommands {
275
275
  this.eventsThreshold.count = 0;
276
276
  this.eventsThreshold.active = false;
277
277
  this.eventsThreshold.timeActivated = 0;
278
- this.adapter.log.info('Subscribe on all states again');
278
+ this.adapter.log.info('Subscribe to all states again');
279
279
 
280
280
  setTimeout(() => {
281
281
  /*
@@ -331,12 +331,12 @@ class SocketCommandsAdmin extends SocketCommands {
331
331
  }
332
332
 
333
333
  try {
334
- this.adapter.getForeignObject('system.user.' + user, options, (error, obj) => {
334
+ this.adapter.getForeignObject(`system.user.${user}`, options, (error, obj) => {
335
335
  if (obj) {
336
336
  SocketCommands._fixCallback(callback, 'User yet exists');
337
337
  } else {
338
338
  try {
339
- this.adapter.setForeignObject('system.user.' + user, {
339
+ this.adapter.setForeignObject(`system.user.${user}`, {
340
340
  type: 'user',
341
341
  common: {
342
342
  name: user,
@@ -347,25 +347,25 @@ class SocketCommandsAdmin extends SocketCommands {
347
347
  try {
348
348
  this.adapter.setPassword(user, pw, options, callback);
349
349
  } catch (error) {
350
- this.adapter.log.error('[_addUser] cannot set password: ' + error.toString());
350
+ this.adapter.log.error(`[_addUser] cannot set password: ${error.toString()}`);
351
351
  SocketCommands._fixCallback(callback, error);
352
352
  }
353
353
  });
354
354
  } catch (error) {
355
- this.adapter.log.error('[_addUser] cannot save user: ' + error.toString());
355
+ this.adapter.log.error(`[_addUser] cannot save user: ${error.toString()}`);
356
356
  SocketCommands._fixCallback(callback, error);
357
357
  }
358
358
  }
359
359
  });
360
360
  } catch (error) {
361
- this.adapter.log.error('[_addUser] cannot read user: ' + error.toString());
361
+ this.adapter.log.error(`[_addUser] cannot read user: ${error.toString()}`);
362
362
  SocketCommands._fixCallback(callback, error);
363
363
  }
364
364
  }
365
365
 
366
366
  _delUser(user, options, callback) {
367
367
  try {
368
- this.adapter.getForeignObject('system.user.' + user, options, (error, obj) => {
368
+ this.adapter.getForeignObject(`system.user.${user}`, options, (error, obj) => {
369
369
  if (error || !obj) {
370
370
  SocketCommands._fixCallback(callback, 'User does not exist');
371
371
  } else {
@@ -373,18 +373,18 @@ class SocketCommandsAdmin extends SocketCommands {
373
373
  SocketCommands._fixCallback(callback, 'Cannot delete user, while is system user');
374
374
  } else {
375
375
  try {
376
- this.adapter.delForeignObject('system.user.' + user, options, error =>
376
+ this.adapter.delForeignObject(`system.user.${user}`, options, error =>
377
377
  // Remove this user from all groups in web client
378
378
  SocketCommands._fixCallback(callback, error));
379
379
  } catch (error) {
380
- this.adapter.log.error('[_delUser] cannot delete user: ' + error.toString());
380
+ this.adapter.log.error(`[_delUser] cannot delete user: ${error.toString()}`);
381
381
  SocketCommands._fixCallback(callback, error);
382
382
  }
383
383
  }
384
384
  }
385
385
  });
386
386
  } catch (error) {
387
- this.adapter.log.error('[_delUser] cannot read user: ' + error.toString());
387
+ this.adapter.log.error(`[_delUser] cannot read user: ${error.toString()}`);
388
388
  SocketCommands._fixCallback(callback, error);
389
389
  }
390
390
  }
@@ -437,14 +437,14 @@ class SocketCommandsAdmin extends SocketCommands {
437
437
  }
438
438
  });
439
439
  } catch (error) {
440
- this.adapter.log.error('[_addGroup] cannot read group: ' + error.toString());
440
+ this.adapter.log.error(`[_addGroup] cannot read group: ${error.toString()}`);
441
441
  SocketCommands._fixCallback(callback, error);
442
442
  }
443
443
  }
444
444
 
445
445
  _delGroup(group, options, callback) {
446
446
  try {
447
- this.adapter.getForeignObject('system.group.' + group, options, (error, obj) => {
447
+ this.adapter.getForeignObject(`system.group.${group}`, options, (error, obj) => {
448
448
  if (error || !obj) {
449
449
  SocketCommands._fixCallback(callback, 'Group does not exist');
450
450
  } else {
@@ -453,7 +453,7 @@ class SocketCommandsAdmin extends SocketCommands {
453
453
  } else {
454
454
  try {
455
455
  this.adapter.delForeignObject(`system.group.${group}`, options, error =>
456
- // Remove this group from all users in web client
456
+ // Remove this group from all users in the web client
457
457
  SocketCommands._fixCallback(callback, error));
458
458
  } catch (error) {
459
459
  this.adapter.log.error(`[_delGroup] cannot delete group: ${error.toString()}`);
@@ -463,13 +463,13 @@ class SocketCommandsAdmin extends SocketCommands {
463
463
  }
464
464
  });
465
465
  } catch (error) {
466
- this.adapter.log.error('[_delGroup] cannot read group: ' + error.toString());
466
+ this.adapter.log.error(`[_delGroup] cannot read group: ${error.toString()}`);
467
467
  SocketCommands._fixCallback(callback, error);
468
468
  }
469
469
  }
470
470
 
471
471
  static _checkObject(obj, options, flag) {
472
- // read rights of object
472
+ // read rights of the object
473
473
  if (!obj || !obj.common || !obj.acl || flag === 'list') {
474
474
  return true;
475
475
  }
@@ -572,7 +572,7 @@ class SocketCommandsAdmin extends SocketCommands {
572
572
  };
573
573
 
574
574
  this.commands['addGroup'] = (socket, group, desc, acl, callback) => {
575
- // Add new group.
575
+ // Add a new group.
576
576
  // @param {string} group - user name, like 'benjamin
577
577
  // @param {string} desc - optional description
578
578
  // @param {object} acl - optional access control list object, like `{"object":{"list":true,"read":true,"write":false,"delete":false},"state":{"list":true,"read":true,"write":true,"create":true,"delete":false},"users":{"list":true,"read":true,"write":false,"create":false,"delete":false},"other":{"execute":false,"http":true,"sendto":false},"file":{"list":true,"read":true,"write":false,"create":false,"delete":false}}`
@@ -584,7 +584,7 @@ class SocketCommandsAdmin extends SocketCommands {
584
584
  };
585
585
 
586
586
  this.commands['delGroup'] = (socket, group, callback) => {
587
- // Delete existing group. Administrator group cannot be deleted.
587
+ // Delete the existing group. Administrator group cannot be deleted.
588
588
  // @param {string} group - group name, like 'users`
589
589
  // @param {function} callback - `function (error)`
590
590
  if (this._checkPermissions(socket, 'delGroup', callback, group)) {
@@ -603,7 +603,7 @@ class SocketCommandsAdmin extends SocketCommands {
603
603
  this.adapter.setPassword(user, pass, {user: socket._acl.user}, (error, ...args) =>
604
604
  SocketCommands._fixCallback(callback, error, ...args));
605
605
  } catch (error) {
606
- this.adapter.log.error('[_changePassword] ERROR: ' + error.toString());
606
+ this.adapter.log.error(`[_changePassword] ERROR: ${error.toString()}`);
607
607
  SocketCommands._fixCallback(callback, error);
608
608
  }
609
609
  }
@@ -612,9 +612,9 @@ class SocketCommandsAdmin extends SocketCommands {
612
612
 
613
613
  _initCommandsAdmin() {
614
614
  this.commands['getHostByIp'] = (socket, ip, callback) => {
615
- // Read host object by IP address
615
+ // Read the host object by IP address
616
616
  // @param {string} ip - ip address. IPv4 or IPv6
617
- // @param {function} callback - `function (ip, obj)`. If host not found, obj is null
617
+ // @param {function} callback - `function (ip, obj)`. If host is not found, obj is null
618
618
  if (typeof callback !== 'function') {
619
619
  return this.adapter.log.warn('[getHostByIp] Invalid callback');
620
620
  }
@@ -648,7 +648,7 @@ class SocketCommandsAdmin extends SocketCommands {
648
648
  callback(ip, null);
649
649
  });
650
650
  } catch (error) {
651
- this.adapter.log.error('[_changePassword] ERROR: ' + error.toString());
651
+ this.adapter.log.error(`[_changePassword] ERROR: ${error.toString()}`);
652
652
  SocketCommands._fixCallback(callback, error);
653
653
  }
654
654
  }
@@ -680,7 +680,7 @@ class SocketCommandsAdmin extends SocketCommands {
680
680
  if (timeout) {
681
681
  let result = {list: []};
682
682
 
683
- // deliver file list
683
+ // deliver the file list
684
684
  try {
685
685
  const config = this.adapter.systemConfig;
686
686
  // detect file log
@@ -742,7 +742,7 @@ class SocketCommandsAdmin extends SocketCommands {
742
742
  };
743
743
 
744
744
  this.commands['delState'] = (socket, id, callback) => {
745
- // Delete state. Corresponding object will be deleted too.
745
+ // Delete state. The corresponding object will be deleted too.
746
746
  // @param {string} id - state ID
747
747
  // @param {function} callback - `function (error)`
748
748
  if (this._checkPermissions(socket, 'delState', callback, id)) {
@@ -763,7 +763,7 @@ class SocketCommandsAdmin extends SocketCommands {
763
763
  // commands will be executed on host/controller
764
764
  // following response commands are expected: cmdStdout, cmdStderr, cmdExit
765
765
  this.commands['cmdExec'] = (socket, host, id, cmd, callback) => {
766
- // Execute shell command on host/controller. Following response commands are expected: ´cmdStdout, cmdStderr, cmdExit´
766
+ // Execute the shell command on host/controller. Following response commands are expected: ´cmdStdout, cmdStderr, cmdExit´
767
767
  // @param {string} host - host name, like 'system.host.raspberrypi'
768
768
  // @param {string} id - session ID, like `Date.now()´. This session ID will come in events `cmdStdout, cmdStderr, cmdExit`
769
769
  // @param {string} cmd - command
@@ -783,7 +783,7 @@ class SocketCommandsAdmin extends SocketCommands {
783
783
  };
784
784
 
785
785
  this.commands['eventsThreshold'] = (socket, isActive) => {
786
- // Used only for admin to limit number of events to front-end.
786
+ // Used only for admin to the limited number of events to front-end.
787
787
  // @param {boolean} isActive - if true, then events will be limited
788
788
  if (!isActive) {
789
789
  this.disableEventThreshold(true);
@@ -811,14 +811,14 @@ class SocketCommandsAdmin extends SocketCommands {
811
811
  };
812
812
 
813
813
  this.commands['checkFeatureSupported'] = (socket, feature, callback) => {
814
- // Checks if same feature is supported by current js-controller
814
+ // Checks, if the same feature is supported by the current js-controller
815
815
  // @param {string} feature - feature name like `CONTROLLER_LICENSE_MANAGER`
816
816
  // @param {function} callback - `function (error, isSupported)`
817
817
  SocketCommands._fixCallback(callback, null, this.adapter.supportsFeature && this.adapter.supportsFeature(feature));
818
818
  };
819
819
 
820
820
  this.commands['decrypt'] = (socket, encryptedText, callback) => {
821
- // Decrypts text with system secret key
821
+ // Decrypts text with the system secret key
822
822
  // @param {string} encryptedText - encrypted text
823
823
  // @param {function} callback - `function (error, decryptedText)`
824
824
  if (this.secret) {
@@ -842,7 +842,7 @@ class SocketCommandsAdmin extends SocketCommands {
842
842
  };
843
843
 
844
844
  this.commands['encrypt'] = (socket, plainText, callback) => {
845
- // Encrypts text with system secret key
845
+ // Encrypts text with the system secret key
846
846
  // @param {string} plainText - normal text
847
847
  // @param {function} callback - `function (error, encryptedText)`
848
848
  if (this.secret) {
@@ -922,7 +922,7 @@ class SocketCommandsAdmin extends SocketCommands {
922
922
  .then(() =>
923
923
  callback(null, {
924
924
  strict: false,
925
- configs
925
+ configs,
926
926
  })
927
927
  );
928
928
  });
@@ -1010,7 +1010,7 @@ class SocketCommandsAdmin extends SocketCommands {
1010
1010
  adminTab: obj.common.adminTab,
1011
1011
  name: obj.common.name,
1012
1012
  icon: obj.common.icon,
1013
- enabled: obj.common.enabled
1013
+ enabled: obj.common.enabled,
1014
1014
  };
1015
1015
  });
1016
1016
 
@@ -1106,7 +1106,7 @@ class SocketCommandsAdmin extends SocketCommands {
1106
1106
  // @param {function} callback - `function (error, repository)`, where `repository` is an object like `{'javascript': {version: '1.0.1', icon}, 'admin': {version: '1.0.1', icon}}`
1107
1107
  if (this._checkPermissions(socket, 'sendToHost', callback)) {
1108
1108
  this._sendToHost(host, 'getRepository', null, data => {
1109
- // Extract only version and icon
1109
+ // Extract only the version and icon
1110
1110
  const result = {};
1111
1111
  data && Object.keys(data).forEach(name => result[name] = {
1112
1112
  version: data[name].version,
@@ -1210,7 +1210,7 @@ class SocketCommandsAdmin extends SocketCommands {
1210
1210
  }
1211
1211
 
1212
1212
  this.commands['extendObject'] = (socket, id, obj, callback) => {
1213
- // Extend existing object
1213
+ // Extend the existing object
1214
1214
  // @param {string} id - object ID
1215
1215
  // @param {object} obj - new parts of the object, like `{common: {name: 'new name'}}`
1216
1216
  // @param {function} callback - `function (error)`
@@ -1251,7 +1251,7 @@ class SocketCommandsAdmin extends SocketCommands {
1251
1251
  };
1252
1252
 
1253
1253
  this.commands['delObject'] = (socket, id, options, callback) => {
1254
- // Delete object or objects recursively. Objects with `dontDelete` cannot be deleted.
1254
+ // Delete an object or objects recursively. Objects with `dontDelete` cannot be deleted.
1255
1255
  // @param {string} id - Object ID like, 'adapterName.0.channel'
1256
1256
  // @param {string} options - `{recursive: true}`
1257
1257
  // @param {function} callback - `function (error)`
@@ -271,11 +271,9 @@ class SocketCommon {
271
271
 
272
272
  this._updateConnectedInfo();
273
273
 
274
- const commands = this.commands.getCommandHandler();
275
-
276
- if (!commands['name']) {
274
+ if (!this.commands.getCommandHandler('name')) {
277
275
  // socket sends its name => update list of sockets
278
- commands['name'] = (_socket, name, cb) => {
276
+ this.addCommandHandler('name', (_socket, name, cb) => {
279
277
  this.adapter.log.debug(`Connection from "${name}"`);
280
278
  if (_socket._name === undefined) {
281
279
  _socket._name = name;
@@ -287,7 +285,7 @@ class SocketCommon {
287
285
  }
288
286
 
289
287
  typeof cb === 'function' && cb();
290
- };
288
+ });
291
289
  }
292
290
 
293
291
  this.commands.applyCommands(socket);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/socket-classes",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "description": "ioBroker server-side web sockets",
5
5
  "author": {
6
6
  "name": "bluefox",
@@ -21,13 +21,13 @@
21
21
  "url": "https://github.com/ioBroker/ioBroker.socket-classes"
22
22
  },
23
23
  "dependencies": {
24
- "@iobroker/adapter-core": "^2.6.7",
24
+ "@iobroker/adapter-core": "^2.6.8",
25
25
  "passport": "^0.6.0",
26
26
  "cookie-parser": "^1.4.6",
27
- "axios": "^1.3.4"
27
+ "axios": "^1.4.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@alcalzone/release-script": "^3.5.9",
30
+ "@alcalzone/release-script": "^3.6.0",
31
31
  "@alcalzone/release-script-plugin-license": "^3.5.9",
32
32
  "iobroker.js-controller": "dev",
33
33
  "gulp": "^4.0.2",
@@ -51,6 +51,7 @@
51
51
  "release-patch": "release-script patch --yes",
52
52
  "release-minor": "release-script minor --yes",
53
53
  "release-major": "release-script major --yes",
54
+ "update-packages": "ncu --upgrade",
54
55
  "docs": "gulp"
55
56
  },
56
57
  "license": "MIT",