@iobroker/socket-classes 1.5.6 → 1.6.1
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 +9 -6
- package/lib/socketCommon.js +4 -1
- package/package.json +10 -12
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @iobroker/socket-classes
|
|
2
2
|
|
|
3
|
-
This library is used for following adapters:
|
|
3
|
+
This library is used at least for the following adapters:
|
|
4
4
|
- [iobroker.admin](https://github.com/ioBroker/ioBroker.admin)
|
|
5
5
|
- [iobroker.cloud](https://github.com/ioBroker/ioBroker.cloud)
|
|
6
6
|
- [iobroker.socketio](https://github.com/ioBroker/ioBroker.socketio)
|
|
@@ -9,7 +9,7 @@ This library is used for following adapters:
|
|
|
9
9
|
- [iobroker.iot](https://github.com/ioBroker/ioBroker.iot)
|
|
10
10
|
|
|
11
11
|
## Usage as admin
|
|
12
|
-
```
|
|
12
|
+
```js
|
|
13
13
|
const TTL_SEC = 3600;
|
|
14
14
|
|
|
15
15
|
const SocketAdmin = require('@iobroker/socket-classes').SocketAdmin;
|
|
@@ -40,7 +40,7 @@ io.close();
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Usage as socket (ws or socketio)
|
|
43
|
-
```
|
|
43
|
+
```js
|
|
44
44
|
const TTL_SEC = 3600;
|
|
45
45
|
|
|
46
46
|
const ws = require('@iobroker/ws-server');
|
|
@@ -65,12 +65,12 @@ io.close();
|
|
|
65
65
|
|
|
66
66
|
## GUI subscribes
|
|
67
67
|
GUI client can send to desired instance the `subscribe` message
|
|
68
|
-
```
|
|
68
|
+
```js
|
|
69
69
|
socket.emit('clientSubscribe', 'cameras.0', 'startCamera', {width: 640, height: 480}, result => console.log('Started: ' + result));
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
The instance 'cameras.0' will receive message `clientSubscribe` with information who want to receive messages.
|
|
73
|
-
```
|
|
73
|
+
```js
|
|
74
74
|
adapter.on('message', obj => {
|
|
75
75
|
if (obj?.command === 'clientSubscribe') {
|
|
76
76
|
if (obj?.message.type && obj.message.type.startsWith('startCamera/')) {
|
|
@@ -103,7 +103,7 @@ adapter.on('message', obj => {
|
|
|
103
103
|
|
|
104
104
|
and after that client will receive messages from instance
|
|
105
105
|
|
|
106
|
-
```
|
|
106
|
+
```js
|
|
107
107
|
function sendImage(camera, data) {
|
|
108
108
|
this.subscribes.forEach(it => {
|
|
109
109
|
if (it.camera !== camera) {
|
|
@@ -979,6 +979,9 @@ Read all instances of the given adapter, or all instances of all adapters if ada
|
|
|
979
979
|
-->
|
|
980
980
|
|
|
981
981
|
## Changelog
|
|
982
|
+
### 1.6.1 (2024-10-05)
|
|
983
|
+
* (bluefox) Added support of iobroker.SocketIO with typescript
|
|
984
|
+
|
|
982
985
|
### 1.5.6 (2024-06-26)
|
|
983
986
|
* (bluefox) Corrected call of getObjectView with null parameter
|
|
984
987
|
|
package/lib/socketCommon.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Class Socket
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2014-
|
|
4
|
+
* Copyright 2014-2024 bluefox <dogafox@gmail.com>,
|
|
5
5
|
* MIT License
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
@@ -71,6 +71,9 @@ class SocketCommon {
|
|
|
71
71
|
if (typeof socketClass.listen === 'function') {
|
|
72
72
|
// old socket.io@2.x and ws
|
|
73
73
|
this.server = socketClass.listen(server, socketOptions);
|
|
74
|
+
} else if (socketClass.constructor) {
|
|
75
|
+
// iobroker socket
|
|
76
|
+
this.server = new socketClass(server, socketOptions);
|
|
74
77
|
} else {
|
|
75
78
|
// socket.io 4.x
|
|
76
79
|
this.server = socketClass(server, socketOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/socket-classes",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "ioBroker server-side web sockets",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "bluefox",
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
"url": "https://github.com/ioBroker/ioBroker.socket-classes"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@iobroker/adapter-core": "^3.
|
|
25
|
-
"axios": "^1.7.
|
|
24
|
+
"@iobroker/adapter-core": "^3.2.2",
|
|
25
|
+
"axios": "^1.7.7",
|
|
26
26
|
"cookie-parser": "^1.4.6",
|
|
27
27
|
"passport": "^0.7.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@alcalzone/release-script": "^3.
|
|
30
|
+
"@alcalzone/release-script": "^3.8.0",
|
|
31
31
|
"@alcalzone/release-script-plugin-license": "^3.7.0",
|
|
32
|
-
"@foxriver76/eslint-config": "^1.0.
|
|
33
|
-
"chai": "^4.
|
|
32
|
+
"@foxriver76/eslint-config": "^1.0.5",
|
|
33
|
+
"chai": "^4.5.0",
|
|
34
34
|
"gulp": "^4.0.2",
|
|
35
|
-
"iobroker.js-controller": "^6.0.
|
|
36
|
-
"mocha": "^10.
|
|
35
|
+
"iobroker.js-controller": "^6.0.11",
|
|
36
|
+
"mocha": "^10.7.3"
|
|
37
37
|
},
|
|
38
38
|
"bugs": {
|
|
39
39
|
"url": "https://github.com/ioBroker/ioBroker.web/issues"
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"release-minor": "release-script minor --no-update-lockfile --yes",
|
|
55
55
|
"release-major": "release-script major --no-update-lockfile --yes",
|
|
56
56
|
"update-packages": "ncu --upgrade",
|
|
57
|
+
"npm": "npm install --ignore-script",
|
|
57
58
|
"docs": "gulp"
|
|
58
59
|
},
|
|
59
60
|
"license": "MIT",
|
|
@@ -62,8 +63,5 @@
|
|
|
62
63
|
"name": "bluefox",
|
|
63
64
|
"email": "dogafox@gmail.com"
|
|
64
65
|
}
|
|
65
|
-
]
|
|
66
|
-
"overrides": {
|
|
67
|
-
"@iobroker/adapter-core": "^3.1.6"
|
|
68
|
-
}
|
|
66
|
+
]
|
|
69
67
|
}
|