@iobroker/socket-classes 0.4.4 → 0.4.7
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 -0
- package/lib/socketCommands.js +16 -2
- package/lib/socketCommon.js +17 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -69,6 +69,15 @@ io.close();
|
|
|
69
69
|
-->
|
|
70
70
|
|
|
71
71
|
## Changelog
|
|
72
|
+
### 0.4.7 (2022-06-20)
|
|
73
|
+
* (bluefox) Allowed to overload system language
|
|
74
|
+
|
|
75
|
+
### 0.4.6 (2022-06-20)
|
|
76
|
+
* (bluefox) updated `passport`
|
|
77
|
+
|
|
78
|
+
### 0.4.5 (2022-06-20)
|
|
79
|
+
* (bluefox) allow to run socket.io behind reverse proxy
|
|
80
|
+
|
|
72
81
|
### 0.4.4 (2022-06-09)
|
|
73
82
|
* (bluefox) Do not show requireLog message
|
|
74
83
|
|
package/lib/socketCommands.js
CHANGED
|
@@ -217,6 +217,10 @@ class SocketCommands {
|
|
|
217
217
|
if (socket && socket.subscribe && socket.subscribe[type] && this._updateSession(socket)) {
|
|
218
218
|
return !!socket.subscribe[type].find(sub => {
|
|
219
219
|
if (sub.regex.test(id)) {
|
|
220
|
+
// replace language
|
|
221
|
+
if (this.adapter._language && id === 'system.config' && obj.common) {
|
|
222
|
+
obj.common.language = this.adapter._language;
|
|
223
|
+
}
|
|
220
224
|
socket.emit(type, id, obj);
|
|
221
225
|
return true;
|
|
222
226
|
}
|
|
@@ -1028,8 +1032,13 @@ class SocketCommands {
|
|
|
1028
1032
|
__initCommandsObjects() {
|
|
1029
1033
|
this.commands['getObject'] = (socket, id, callback) => {
|
|
1030
1034
|
if (this._checkPermissions(socket, 'getObject', callback, id)) {
|
|
1031
|
-
this.adapter.getForeignObject(id, {user: socket._acl.user}, (err,
|
|
1032
|
-
|
|
1035
|
+
this.adapter.getForeignObject(id, {user: socket._acl.user}, (err, obj) => {
|
|
1036
|
+
// overload language from current instance
|
|
1037
|
+
if (this.adapter._language && id === 'system.config' && obj.common) {
|
|
1038
|
+
obj.common.language = this.adapter._language;
|
|
1039
|
+
}
|
|
1040
|
+
SocketCommands._fixCallback(callback, err, obj);
|
|
1041
|
+
});
|
|
1033
1042
|
}
|
|
1034
1043
|
};
|
|
1035
1044
|
|
|
@@ -1038,6 +1047,11 @@ class SocketCommands {
|
|
|
1038
1047
|
if (this._checkPermissions(socket, 'getObjects', callback)) {
|
|
1039
1048
|
this.adapter.getForeignObjects('*', 'state', 'rooms', {user: socket._acl.user}, (err, objs) => {
|
|
1040
1049
|
if (typeof callback === 'function') {
|
|
1050
|
+
// overload language
|
|
1051
|
+
if (this.adapter._language && objs['system.config'] && objs['system.config'].common) {
|
|
1052
|
+
objs['system.config'].common.language = this.adapter._language;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1041
1055
|
callback(err, objs);
|
|
1042
1056
|
} else {
|
|
1043
1057
|
this.adapter.log.warn('[getObjects] Invalid callback');
|
package/lib/socketCommon.js
CHANGED
|
@@ -18,6 +18,7 @@ class SocketCommon {
|
|
|
18
18
|
this.infoTimeout = null;
|
|
19
19
|
this.eventHandlers = {};
|
|
20
20
|
this.store = null; // will be set in __initAuthentication
|
|
21
|
+
this.adapter._language = this.settings.language;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
__getIsNoDisconnect() {
|
|
@@ -75,6 +76,10 @@ class SocketCommon {
|
|
|
75
76
|
this.server = socketClass(server, socketOptions);
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
if (typeof this.server.of === 'function') {
|
|
80
|
+
this.allNamespaces = this.server.of(/.*/);
|
|
81
|
+
}
|
|
82
|
+
|
|
78
83
|
server.__inited = true;
|
|
79
84
|
this.adapter.log.info(`${this.settings.secure ? 'Secure ' : ''}socket.io server listening on port ${this.settings.port}`);
|
|
80
85
|
}
|
|
@@ -93,6 +98,11 @@ class SocketCommon {
|
|
|
93
98
|
this.eventHandlers.connect && this.eventHandlers.connect(socket);
|
|
94
99
|
this._initSocket(socket, cb);
|
|
95
100
|
});
|
|
101
|
+
// support of dynamic namespaces (because of reverse proxy)
|
|
102
|
+
this.allNamespaces && this.allNamespaces.on('connection', (socket, cb) => {
|
|
103
|
+
this.eventHandlers.connect && this.eventHandlers.connect(socket);
|
|
104
|
+
this._initSocket(socket, cb);
|
|
105
|
+
});
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
this.server.on('error', (error, details) => {
|
|
@@ -101,6 +111,13 @@ class SocketCommon {
|
|
|
101
111
|
this.adapter.log.error(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
|
|
102
112
|
}
|
|
103
113
|
});
|
|
114
|
+
// support of dynamic namespaces (because of reverse proxy)
|
|
115
|
+
this.allNamespaces && this.allNamespaces.on('error', (error, details) => {
|
|
116
|
+
// ignore "failed connection" as it already shown
|
|
117
|
+
if (!error || !error.message || !error.message.includes('failed connection')) {
|
|
118
|
+
this.adapter.log.error(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
104
121
|
|
|
105
122
|
this._updateConnectedInfo();
|
|
106
123
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/socket-classes",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "ioBroker server-side web sockets",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "bluefox",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://github.com/ioBroker/ioBroker.socket-classes"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"passport": "^0.
|
|
24
|
+
"passport": "^0.6.0",
|
|
25
25
|
"cookie-parser": "^1.4.6",
|
|
26
26
|
"axios": "^0.27.2"
|
|
27
27
|
},
|