@iobroker/socket-classes 1.4.0 → 1.4.2
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 +6 -0
- package/lib/socketCommands.js +20 -39
- package/lib/socketCommandsAdmin.js +2 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -978,6 +978,12 @@ Read all instances of the given adapter, or all instances of all adapters if ada
|
|
|
978
978
|
-->
|
|
979
979
|
|
|
980
980
|
## Changelog
|
|
981
|
+
### 1.4.2 (2023-09-28)
|
|
982
|
+
* (bluefox) Corrected error by unsubscribing on client disconnect
|
|
983
|
+
|
|
984
|
+
### 1.4.1 (2023-09-12)
|
|
985
|
+
* (foxriver76) do not cancel follow subscribes if one subscribe has an error
|
|
986
|
+
|
|
981
987
|
### 1.4.0 (2023-09-11)
|
|
982
988
|
* (foxriver76) fixed crash on invalid patterns with js-controller version 5
|
|
983
989
|
|
package/lib/socketCommands.js
CHANGED
|
@@ -309,15 +309,13 @@ class SocketCommands {
|
|
|
309
309
|
try {
|
|
310
310
|
await this.adapter.subscribeForeignStatesAsync(pattern, options);
|
|
311
311
|
} catch (e) {
|
|
312
|
-
this.adapter.log.error(`
|
|
313
|
-
return
|
|
312
|
+
this.adapter.log.error(`Cannot subscribe "${pattern}": ${e.message}`)
|
|
314
313
|
}
|
|
315
314
|
} else if (type === 'objectChange') {
|
|
316
315
|
try {
|
|
317
316
|
this.adapter.subscribeForeignObjects && await this.adapter.subscribeForeignObjects(pattern, options);
|
|
318
317
|
} catch (e) {
|
|
319
|
-
this.adapter.log.error(`
|
|
320
|
-
return
|
|
318
|
+
this.adapter.log.error(`Cannot subscribe "${pattern}": ${e.message}`)
|
|
321
319
|
}
|
|
322
320
|
} else if (type === 'log') {
|
|
323
321
|
if (!this.logEnabled && this.adapter.requireLog) {
|
|
@@ -328,8 +326,7 @@ class SocketCommands {
|
|
|
328
326
|
try {
|
|
329
327
|
await this.adapter.subscribeForeignFiles(pattern, patternFile, options);
|
|
330
328
|
} catch (e) {
|
|
331
|
-
this.adapter.log.error(`
|
|
332
|
-
return
|
|
329
|
+
this.adapter.log.error(`Cannot subscribe "${pattern}": ${e.message}`)
|
|
333
330
|
}
|
|
334
331
|
}
|
|
335
332
|
} else {
|
|
@@ -372,18 +369,15 @@ class SocketCommands {
|
|
|
372
369
|
try {
|
|
373
370
|
await this.adapter.unsubscribeForeignStatesAsync(pattern, options);
|
|
374
371
|
} catch (e) {
|
|
375
|
-
this.adapter.log.error(`
|
|
376
|
-
return
|
|
372
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
377
373
|
}
|
|
378
374
|
} else if (type === 'objectChange') {
|
|
379
375
|
try {
|
|
380
376
|
this.adapter.unsubscribeForeignObjects && await this.adapter.unsubscribeForeignObjectsAsync(pattern, options);
|
|
381
377
|
} catch (e) {
|
|
382
|
-
this.adapter.log.error(`
|
|
383
|
-
return
|
|
378
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
384
379
|
}
|
|
385
380
|
} else if (type === 'log') {
|
|
386
|
-
//console.log((socket._name || socket.id) + ' requireLog false');
|
|
387
381
|
if (this.logEnabled && this.adapter.requireLog) {
|
|
388
382
|
this.logEnabled = false;
|
|
389
383
|
this.adapter.requireLog(false, options);
|
|
@@ -392,8 +386,7 @@ class SocketCommands {
|
|
|
392
386
|
try {
|
|
393
387
|
this.adapter.unsubscribeForeignFiles && await this.adapter.unsubscribeForeignFiles(pattern, patternFile, options);
|
|
394
388
|
} catch (e) {
|
|
395
|
-
this.adapter.log.error(`
|
|
396
|
-
return
|
|
389
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
397
390
|
}
|
|
398
391
|
}
|
|
399
392
|
delete this.subscribes[type][pattern];
|
|
@@ -414,15 +407,13 @@ class SocketCommands {
|
|
|
414
407
|
try {
|
|
415
408
|
await this.adapter.unsubscribeForeignStatesAsync(pattern, options);
|
|
416
409
|
} catch (e) {
|
|
417
|
-
this.adapter.log.error(`
|
|
418
|
-
return
|
|
410
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
419
411
|
}
|
|
420
412
|
} else if (type === 'objectChange') {
|
|
421
413
|
try {
|
|
422
414
|
this.adapter.unsubscribeForeignObjects && await this.adapter.unsubscribeForeignObjectsAsync(pattern, options);
|
|
423
415
|
} catch (e) {
|
|
424
|
-
this.adapter.log.error(`
|
|
425
|
-
return
|
|
416
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
426
417
|
}
|
|
427
418
|
} else if (type === 'log') {
|
|
428
419
|
if (this.adapter.requireLog && this.logEnabled) {
|
|
@@ -433,8 +424,7 @@ class SocketCommands {
|
|
|
433
424
|
try {
|
|
434
425
|
this.adapter.unsubscribeForeignFiles && await this.adapter.unsubscribeForeignFiles(pattern, patternFile, options);
|
|
435
426
|
} catch (e) {
|
|
436
|
-
this.adapter.log.error(`
|
|
437
|
-
return
|
|
427
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
438
428
|
}
|
|
439
429
|
}
|
|
440
430
|
delete this.subscribes[type][key];
|
|
@@ -446,15 +436,13 @@ class SocketCommands {
|
|
|
446
436
|
try {
|
|
447
437
|
await this.adapter.unsubscribeForeignStatesAsync(pattern, options);
|
|
448
438
|
} catch (e) {
|
|
449
|
-
this.adapter.log.error(`
|
|
450
|
-
return
|
|
439
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
451
440
|
}
|
|
452
441
|
} else if (type === 'objectChange') {
|
|
453
442
|
try {
|
|
454
443
|
this.adapter.unsubscribeForeignObjects && await this.adapter.unsubscribeForeignObjectsAsync(pattern, options);
|
|
455
444
|
} catch (e) {
|
|
456
|
-
this.adapter.log.error(`
|
|
457
|
-
return
|
|
445
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
458
446
|
}
|
|
459
447
|
} else if (type === 'log') {
|
|
460
448
|
// console.log((socket._name || socket.id) + ' requireLog false');
|
|
@@ -467,8 +455,7 @@ class SocketCommands {
|
|
|
467
455
|
try {
|
|
468
456
|
this.adapter.unsubscribeForeignFiles && await this.adapter.unsubscribeForeignFiles(id, fileName, options);
|
|
469
457
|
} catch (e) {
|
|
470
|
-
this.adapter.log.error(`
|
|
471
|
-
return
|
|
458
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
472
459
|
}
|
|
473
460
|
}
|
|
474
461
|
}
|
|
@@ -502,15 +489,13 @@ class SocketCommands {
|
|
|
502
489
|
try {
|
|
503
490
|
await this.adapter.subscribeForeignStatesAsync(pattern, options);
|
|
504
491
|
} catch (e) {
|
|
505
|
-
this.adapter.log.error(`
|
|
506
|
-
return
|
|
492
|
+
this.adapter.log.error(`Cannot subscribe "${pattern}": ${e.message}`)
|
|
507
493
|
}
|
|
508
494
|
} else if (type === 'objectChange') {
|
|
509
495
|
try {
|
|
510
496
|
this.adapter.subscribeForeignObjects && await this.adapter.subscribeForeignObjectsAsync(pattern, options);
|
|
511
497
|
} catch (e) {
|
|
512
|
-
this.adapter.log.error(`
|
|
513
|
-
return
|
|
498
|
+
this.adapter.log.error(`Cannot subscribe "${pattern}": ${e.message}`)
|
|
514
499
|
}
|
|
515
500
|
} else if (type === 'log') {
|
|
516
501
|
if (this.adapter.requireLog && !this.logEnabled) {
|
|
@@ -522,8 +507,7 @@ class SocketCommands {
|
|
|
522
507
|
try {
|
|
523
508
|
this.adapter.subscribeForeignFiles && await this.adapter.subscribeForeignFiles(id, fileName, options);
|
|
524
509
|
} catch (e) {
|
|
525
|
-
this.adapter.log.error(`
|
|
526
|
-
return
|
|
510
|
+
this.adapter.log.error(`Cannot subscribe "${pattern}": ${e.message}`)
|
|
527
511
|
}
|
|
528
512
|
}
|
|
529
513
|
} else {
|
|
@@ -560,15 +544,13 @@ class SocketCommands {
|
|
|
560
544
|
try {
|
|
561
545
|
await this.adapter.unsubscribeForeignStatesAsync(pattern, options);
|
|
562
546
|
} catch (e) {
|
|
563
|
-
this.adapter.log.error(`
|
|
564
|
-
return
|
|
547
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
565
548
|
}
|
|
566
549
|
} else if (type === 'objectChange') {
|
|
567
550
|
try {
|
|
568
551
|
this.adapter.unsubscribeForeignObjects && await this.adapter.unsubscribeForeignObjectsAsync(pattern, options);
|
|
569
552
|
} catch (e) {
|
|
570
|
-
this.adapter.log.error(`
|
|
571
|
-
return
|
|
553
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
572
554
|
}
|
|
573
555
|
} else if (type === 'log') {
|
|
574
556
|
if (this.adapter.requireLog && !this.logEnabled) {
|
|
@@ -580,8 +562,7 @@ class SocketCommands {
|
|
|
580
562
|
try {
|
|
581
563
|
this.adapter.unsubscribeForeignFiles && await this.adapter.unsubscribeForeignFiles(id, fileName, options);
|
|
582
564
|
} catch (e) {
|
|
583
|
-
this.adapter.log.error(`
|
|
584
|
-
return
|
|
565
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
585
566
|
}
|
|
586
567
|
}
|
|
587
568
|
delete this.subscribes[type][pattern];
|
|
@@ -1720,7 +1701,7 @@ class SocketCommands {
|
|
|
1720
1701
|
if (pos !== -1) {
|
|
1721
1702
|
this.clientSubscribes[sid][targetInstance].splice(pos, 1);
|
|
1722
1703
|
// inform instance about unsubscription
|
|
1723
|
-
this.adapter.sendTo(targetInstance, 'clientUnsubscribe', {type: [messageType], sid, reason: 'client'});
|
|
1704
|
+
this.adapter.sendTo(targetInstance, 'clientUnsubscribe', { type: [messageType], sid, reason: 'client' });
|
|
1724
1705
|
SocketCommands._fixCallback(callback, null, true);
|
|
1725
1706
|
return;
|
|
1726
1707
|
}
|
|
@@ -1741,7 +1722,7 @@ class SocketCommands {
|
|
|
1741
1722
|
if (this.clientSubscribes[socketId]) {
|
|
1742
1723
|
Object.keys(this.clientSubscribes[socketId]).forEach(targetInstance => {
|
|
1743
1724
|
this.adapter.sendTo(targetInstance, 'clientUnsubscribe', {
|
|
1744
|
-
|
|
1725
|
+
type: this.clientSubscribes[socketId][targetInstance],
|
|
1745
1726
|
sid: socketId,
|
|
1746
1727
|
reason: 'disconnect',
|
|
1747
1728
|
});
|
|
@@ -285,8 +285,7 @@ class SocketCommandsAdmin extends SocketCommands {
|
|
|
285
285
|
try {
|
|
286
286
|
await this.adapter.subscribeForeignStatesAsync(pattern)
|
|
287
287
|
} catch (e) {
|
|
288
|
-
this.adapter.log.error(`
|
|
289
|
-
return
|
|
288
|
+
this.adapter.log.error(`Cannot subscribe "${pattern}": ${e.message}`)
|
|
290
289
|
}
|
|
291
290
|
}
|
|
292
291
|
}, 50);
|
|
@@ -302,14 +301,12 @@ class SocketCommandsAdmin extends SocketCommands {
|
|
|
302
301
|
this.eventsThreshold.timeActivated = Date.now();
|
|
303
302
|
|
|
304
303
|
this.onThresholdChanged && this.onThresholdChanged(true);
|
|
305
|
-
//this.server && this.server.sockets && this.server.sockets.emit('eventsThreshold', true);
|
|
306
304
|
|
|
307
305
|
for (const pattern of Object.keys(this.subscribes.stateChange)) {
|
|
308
306
|
try {
|
|
309
307
|
await this.adapter.unsubscribeForeignStatesAsync(pattern)
|
|
310
308
|
} catch (e) {
|
|
311
|
-
this.adapter.log.error(`
|
|
312
|
-
return
|
|
309
|
+
this.adapter.log.error(`Cannot unsubscribe "${pattern}": ${e.message}`)
|
|
313
310
|
}
|
|
314
311
|
}
|
|
315
312
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/socket-classes",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "ioBroker server-side web sockets",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "bluefox",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"@iobroker/adapter-core": "^3.0.3",
|
|
25
25
|
"passport": "^0.6.0",
|
|
26
26
|
"cookie-parser": "^1.4.6",
|
|
27
|
-
"axios": "^1.
|
|
27
|
+
"axios": "^1.5.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
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",
|
|
34
|
-
"chai": "^4.3.
|
|
34
|
+
"chai": "^4.3.10",
|
|
35
35
|
"mocha": "^10.2.0"
|
|
36
36
|
},
|
|
37
37
|
"bugs": {
|