@iobroker/socket-classes 1.1.3 → 1.1.5
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 +3 -0
- package/lib/socketCommon.js +17 -15
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/socketCommon.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Class Socket
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2014-
|
|
4
|
+
* Copyright 2014-2023 bluefox <dogafox@gmail.com>,
|
|
5
5
|
* MIT License
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
@@ -271,22 +271,24 @@ class SocketCommon {
|
|
|
271
271
|
|
|
272
272
|
this._updateConnectedInfo();
|
|
273
273
|
|
|
274
|
-
this.commands.
|
|
274
|
+
if (!this.commands.getCommandHandler('name')) {
|
|
275
|
+
// socket sends its name => update list of sockets
|
|
276
|
+
this.addCommandHandler('name', (_socket, name, cb) => {
|
|
277
|
+
this.adapter.log.debug(`Connection from "${name}"`);
|
|
278
|
+
if (_socket._name === undefined) {
|
|
279
|
+
_socket._name = name;
|
|
280
|
+
this._updateConnectedInfo();
|
|
281
|
+
} else if (_socket._name !== name) {
|
|
282
|
+
this.adapter.log.warn(`socket ${_socket.id} changed socket name from ${_socket._name} to ${name}`);
|
|
283
|
+
_socket._name = name;
|
|
284
|
+
this._updateConnectedInfo();
|
|
285
|
+
}
|
|
275
286
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (socket._name === undefined) {
|
|
280
|
-
socket._name = name;
|
|
281
|
-
this._updateConnectedInfo();
|
|
282
|
-
} else if (socket._name !== name) {
|
|
283
|
-
this.adapter.log.warn(`socket ${socket.id} changed socket name from ${socket._name} to ${name}`);
|
|
284
|
-
socket._name = name;
|
|
285
|
-
this._updateConnectedInfo();
|
|
286
|
-
}
|
|
287
|
+
typeof cb === 'function' && cb();
|
|
288
|
+
});
|
|
289
|
+
}
|
|
287
290
|
|
|
288
|
-
|
|
289
|
-
});
|
|
291
|
+
this.commands.applyCommands(socket);
|
|
290
292
|
|
|
291
293
|
// disconnect
|
|
292
294
|
socket.on('disconnect', error => {
|