node-opcua-server-discovery 2.156.0 → 2.158.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/dist/mdns_responder.d.ts +2 -4
- package/dist/mdns_responder.js +31 -13
- package/dist/mdns_responder.js.map +1 -1
- package/dist/opcua_discovery_server.d.ts +9 -9
- package/dist/opcua_discovery_server.js +231 -197
- package/dist/opcua_discovery_server.js.map +1 -1
- package/package.json +17 -15
- package/source/mdns_responder.ts +27 -17
- package/source/opcua_discovery_server.ts +311 -249
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-server-discovery",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.158.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module server-discovery",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc -b",
|
|
@@ -12,18 +12,17 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"chalk": "4.1.2",
|
|
14
14
|
"env-paths": "2.2.1",
|
|
15
|
-
"node-opcua-assert": "2.
|
|
16
|
-
"node-opcua-basic-types": "2.
|
|
17
|
-
"node-opcua-certificate-manager": "2.
|
|
18
|
-
"node-opcua-common": "2.
|
|
19
|
-
"node-opcua-debug": "2.
|
|
20
|
-
"node-opcua-
|
|
21
|
-
"node-opcua-
|
|
22
|
-
"node-opcua-
|
|
23
|
-
"node-opcua-
|
|
24
|
-
"node-opcua-service-
|
|
25
|
-
"node-opcua-
|
|
26
|
-
"node-opcua-status-code": "2.153.0",
|
|
15
|
+
"node-opcua-assert": "2.157.0",
|
|
16
|
+
"node-opcua-basic-types": "2.157.0",
|
|
17
|
+
"node-opcua-certificate-manager": "2.157.0",
|
|
18
|
+
"node-opcua-common": "2.158.0",
|
|
19
|
+
"node-opcua-debug": "2.157.0",
|
|
20
|
+
"node-opcua-object-registry": "2.157.0",
|
|
21
|
+
"node-opcua-secure-channel": "2.158.0",
|
|
22
|
+
"node-opcua-server": "2.158.0",
|
|
23
|
+
"node-opcua-service-discovery": "2.158.0",
|
|
24
|
+
"node-opcua-service-endpoints": "2.158.0",
|
|
25
|
+
"node-opcua-status-code": "2.157.0",
|
|
27
26
|
"sterfive-bonjour-service": "1.1.4",
|
|
28
27
|
"thenify-ex": "4.4.0"
|
|
29
28
|
},
|
|
@@ -42,9 +41,12 @@
|
|
|
42
41
|
"internet of things"
|
|
43
42
|
],
|
|
44
43
|
"homepage": "http://node-opcua.github.io/",
|
|
45
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "d92c1c46754548964c3a7821dfec2b52a8522232",
|
|
46
45
|
"files": [
|
|
47
46
|
"dist",
|
|
48
47
|
"source"
|
|
49
|
-
]
|
|
48
|
+
],
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"node-opcua-pki": "5.5.0"
|
|
51
|
+
}
|
|
50
52
|
}
|
package/source/mdns_responder.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
|
|
|
6
6
|
import { ObjectRegistry } from "node-opcua-object-registry";
|
|
7
7
|
import { ServerOnNetwork, serviceToString } from "node-opcua-service-discovery";
|
|
8
8
|
|
|
9
|
-
const debugLog = make_debugLog(
|
|
10
|
-
const doDebug = checkDebugFlag(
|
|
9
|
+
const debugLog = make_debugLog("LDSSERVER");
|
|
10
|
+
const doDebug = checkDebugFlag("LDSSERVER") || true;
|
|
11
11
|
|
|
12
12
|
const registry = new ObjectRegistry();
|
|
13
13
|
|
|
@@ -17,10 +17,10 @@ export class MDNSResponder {
|
|
|
17
17
|
*/
|
|
18
18
|
public registeredServers: ServerOnNetwork[];
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
#bonjour: Bonjour;
|
|
21
|
+
#mDNSBrowser: Browser;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
#recordId: number;
|
|
24
24
|
public lastUpdateDate: Date = new Date();
|
|
25
25
|
|
|
26
26
|
constructor() {
|
|
@@ -28,10 +28,10 @@ export class MDNSResponder {
|
|
|
28
28
|
|
|
29
29
|
this.registeredServers = [];
|
|
30
30
|
|
|
31
|
-
this
|
|
32
|
-
this
|
|
31
|
+
this.#bonjour = new Bonjour();
|
|
32
|
+
this.#recordId = 0;
|
|
33
33
|
|
|
34
|
-
this
|
|
34
|
+
this.#mDNSBrowser = this.#bonjour.find({
|
|
35
35
|
protocol: "tcp",
|
|
36
36
|
type: "opcua-tcp"
|
|
37
37
|
});
|
|
@@ -72,8 +72,8 @@ export class MDNSResponder {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
this
|
|
76
|
-
const recordId = this
|
|
75
|
+
this.#recordId++;
|
|
76
|
+
const recordId = this.#recordId;
|
|
77
77
|
const serverName = service.name;
|
|
78
78
|
|
|
79
79
|
service.txt = service.txt || {};
|
|
@@ -112,23 +112,33 @@ export class MDNSResponder {
|
|
|
112
112
|
this.lastUpdateDate = new Date();
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
-
this.
|
|
115
|
+
this.#mDNSBrowser.on("up", (service: Service) => {
|
|
116
116
|
// istanbul ignore next
|
|
117
117
|
doDebug && debugLog("MDNSResponder : service is up with ", serviceToString(service));
|
|
118
118
|
addService(service);
|
|
119
|
+
// console.log("records " , JSON.stringify(service.records()));
|
|
119
120
|
});
|
|
120
121
|
|
|
121
|
-
this.
|
|
122
|
+
this.#mDNSBrowser.on("down", (service: Service) => {
|
|
122
123
|
// istanbul ignore next
|
|
123
124
|
doDebug && debugLog("MDNSResponder : service is down with ", serviceToString(service));
|
|
124
|
-
|
|
125
125
|
removeService(service);
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
public async dispose(): Promise<void> {
|
|
129
|
+
|
|
130
|
+
if (this.#mDNSBrowser) {
|
|
131
|
+
this.#mDNSBrowser.stop();
|
|
132
|
+
this.#mDNSBrowser = undefined!;
|
|
133
|
+
}
|
|
134
|
+
await new Promise<void>((resolve) => {
|
|
135
|
+
this.#bonjour.unpublishAll(() => {
|
|
136
|
+
this.#bonjour.destroy(() => {
|
|
137
|
+
resolve();
|
|
138
|
+
});
|
|
139
|
+
})
|
|
140
|
+
});
|
|
132
141
|
registry.unregister(this);
|
|
142
|
+
await new Promise<void>((resolve) => setTimeout(resolve, 100));
|
|
133
143
|
}
|
|
134
144
|
}
|