node-opcua-server 2.97.0 → 2.98.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/package.json +43 -43
- package/dist/base_server.d.ts +0 -110
- package/dist/base_server.js +0 -491
- package/dist/base_server.js.map +0 -1
- package/dist/factory.d.ts +0 -12
- package/dist/factory.js +0 -24
- package/dist/factory.js.map +0 -1
- package/dist/filter/check_where_clause_on_address_space.d.ts +0 -3
- package/dist/filter/check_where_clause_on_address_space.js +0 -23
- package/dist/filter/check_where_clause_on_address_space.js.map +0 -1
- package/dist/filter/extract_event_fields.d.ts +0 -10
- package/dist/filter/extract_event_fields.js +0 -18
- package/dist/filter/extract_event_fields.js.map +0 -1
- package/dist/helper.d.ts +0 -10
- package/dist/helper.js +0 -76
- package/dist/helper.js.map +0 -1
- package/dist/history_server_capabilities.d.ts +0 -35
- package/dist/history_server_capabilities.js +0 -44
- package/dist/history_server_capabilities.js.map +0 -1
- package/dist/i_channel_data.d.ts +0 -13
- package/dist/i_channel_data.js +0 -3
- package/dist/i_channel_data.js.map +0 -1
- package/dist/i_register_server_manager.d.ts +0 -16
- package/dist/i_register_server_manager.js +0 -3
- package/dist/i_register_server_manager.js.map +0 -1
- package/dist/i_server_side_publish_engine.d.ts +0 -36
- package/dist/i_server_side_publish_engine.js +0 -50
- package/dist/i_server_side_publish_engine.js.map +0 -1
- package/dist/i_socket_data.d.ts +0 -11
- package/dist/i_socket_data.js +0 -3
- package/dist/i_socket_data.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.js +0 -33
- package/dist/index.js.map +0 -1
- package/dist/monitored_item.d.ts +0 -188
- package/dist/monitored_item.js +0 -1113
- package/dist/monitored_item.js.map +0 -1
- package/dist/node_sampler.d.ts +0 -3
- package/dist/node_sampler.js +0 -80
- package/dist/node_sampler.js.map +0 -1
- package/dist/opcua_server.d.ts +0 -747
- package/dist/opcua_server.js +0 -2429
- package/dist/opcua_server.js.map +0 -1
- package/dist/queue.d.ts +0 -11
- package/dist/queue.js +0 -72
- package/dist/queue.js.map +0 -1
- package/dist/register_server_manager.d.ts +0 -96
- package/dist/register_server_manager.js +0 -585
- package/dist/register_server_manager.js.map +0 -1
- package/dist/register_server_manager_hidden.d.ts +0 -17
- package/dist/register_server_manager_hidden.js +0 -28
- package/dist/register_server_manager_hidden.js.map +0 -1
- package/dist/register_server_manager_mdns_only.d.ts +0 -22
- package/dist/register_server_manager_mdns_only.js +0 -56
- package/dist/register_server_manager_mdns_only.js.map +0 -1
- package/dist/sampling_func.d.ts +0 -3
- package/dist/sampling_func.js +0 -3
- package/dist/sampling_func.js.map +0 -1
- package/dist/server_capabilities.d.ts +0 -148
- package/dist/server_capabilities.js +0 -102
- package/dist/server_capabilities.js.map +0 -1
- package/dist/server_end_point.d.ts +0 -185
- package/dist/server_end_point.js +0 -841
- package/dist/server_end_point.js.map +0 -1
- package/dist/server_engine.d.ts +0 -318
- package/dist/server_engine.js +0 -1775
- package/dist/server_engine.js.map +0 -1
- package/dist/server_publish_engine.d.ts +0 -113
- package/dist/server_publish_engine.js +0 -542
- package/dist/server_publish_engine.js.map +0 -1
- package/dist/server_publish_engine_for_orphan_subscriptions.d.ts +0 -16
- package/dist/server_publish_engine_for_orphan_subscriptions.js +0 -52
- package/dist/server_publish_engine_for_orphan_subscriptions.js.map +0 -1
- package/dist/server_session.d.ts +0 -185
- package/dist/server_session.js +0 -758
- package/dist/server_session.js.map +0 -1
- package/dist/server_subscription.d.ts +0 -421
- package/dist/server_subscription.js +0 -1348
- package/dist/server_subscription.js.map +0 -1
- package/dist/sessions_compatible_for_transfer.d.ts +0 -2
- package/dist/sessions_compatible_for_transfer.js +0 -40
- package/dist/sessions_compatible_for_transfer.js.map +0 -1
- package/dist/user_manager.d.ts +0 -32
- package/dist/user_manager.js +0 -99
- package/dist/user_manager.js.map +0 -1
- package/dist/user_manager_ua.d.ts +0 -3
- package/dist/user_manager_ua.js +0 -40
- package/dist/user_manager_ua.js.map +0 -1
- package/dist/validate_filter.d.ts +0 -5
- package/dist/validate_filter.js +0 -82
- package/dist/validate_filter.js.map +0 -1
package/dist/server_session.js
DELETED
|
@@ -1,758 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @module node-opcua-server
|
|
4
|
-
*/
|
|
5
|
-
// tslint:disable:no-console
|
|
6
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ServerSession = void 0;
|
|
17
|
-
const crypto = require("crypto");
|
|
18
|
-
const events_1 = require("events");
|
|
19
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
20
|
-
const node_opcua_address_space_1 = require("node-opcua-address-space");
|
|
21
|
-
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
22
|
-
const node_opcua_common_1 = require("node-opcua-common");
|
|
23
|
-
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
24
|
-
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
25
|
-
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
26
|
-
const node_opcua_object_registry_1 = require("node-opcua-object-registry");
|
|
27
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
28
|
-
const node_opcua_utils_1 = require("node-opcua-utils");
|
|
29
|
-
const node_opcua_utils_2 = require("node-opcua-utils");
|
|
30
|
-
const server_publish_engine_1 = require("./server_publish_engine");
|
|
31
|
-
const server_subscription_1 = require("./server_subscription");
|
|
32
|
-
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
33
|
-
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
34
|
-
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
|
|
35
|
-
const theWatchDog = new node_opcua_utils_1.WatchDog();
|
|
36
|
-
const registeredNodeNameSpace = 9999;
|
|
37
|
-
function on_channel_abort() {
|
|
38
|
-
debugLog("ON CHANNEL ABORT ON SESSION!!!");
|
|
39
|
-
/**
|
|
40
|
-
* @event channel_aborted
|
|
41
|
-
*/
|
|
42
|
-
this.emit("channel_aborted");
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
* A Server session object.
|
|
47
|
-
*
|
|
48
|
-
* **from OPCUA Spec 1.02:**
|
|
49
|
-
*
|
|
50
|
-
* * Sessions are created to be independent of the underlying communications connection. Therefore, if a communication
|
|
51
|
-
* connection fails, the Session is not immediately affected. The exact mechanism to recover from an underlying
|
|
52
|
-
* communication connection error depends on the SecureChannel mapping as described in Part 6.
|
|
53
|
-
*
|
|
54
|
-
* * Sessions are terminated by the Server automatically if the Client fails to issue a Service request on the Session
|
|
55
|
-
* within the timeout period negotiated by the Server in the CreateSession Service response. This protects the Server
|
|
56
|
-
* against Client failures and against situations where a failed underlying connection cannot be re-established.
|
|
57
|
-
*
|
|
58
|
-
* * Clients shall be prepared to submit requests in a timely manner to prevent the Session from closing automatically.
|
|
59
|
-
*
|
|
60
|
-
* * Clients may explicitly terminate Sessions using the CloseSession Service.
|
|
61
|
-
*
|
|
62
|
-
* * When a Session is terminated, all outstanding requests on the Session are aborted and BadSessionClosed StatusCodes
|
|
63
|
-
* are returned to the Client. In addition, the Server deletes the entry for the Client from its
|
|
64
|
-
* SessionDiagnosticsArray Variable and notifies any other Clients who were subscribed to this entry.
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
|
-
class ServerSession extends events_1.EventEmitter {
|
|
68
|
-
constructor(parent, userManager, sessionTimeout) {
|
|
69
|
-
super();
|
|
70
|
-
this.__status = "new";
|
|
71
|
-
this.sessionName = "";
|
|
72
|
-
this.keepAlive = node_opcua_utils_1.WatchDog.emptyKeepAlive;
|
|
73
|
-
this.parent = parent; // SessionEngine
|
|
74
|
-
ServerSession.registry.register(this);
|
|
75
|
-
this.sessionContext = new node_opcua_address_space_1.SessionContext({
|
|
76
|
-
session: this,
|
|
77
|
-
server: { userManager }
|
|
78
|
-
});
|
|
79
|
-
(0, node_opcua_assert_1.assert)(isFinite(sessionTimeout));
|
|
80
|
-
(0, node_opcua_assert_1.assert)(sessionTimeout >= 0, " sessionTimeout");
|
|
81
|
-
this.sessionTimeout = sessionTimeout;
|
|
82
|
-
const authenticationTokenBuf = crypto.randomBytes(16);
|
|
83
|
-
this.authenticationToken = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeIdType.BYTESTRING, authenticationTokenBuf);
|
|
84
|
-
// the sessionId
|
|
85
|
-
const ownNamespaceIndex = 1; // addressSpace.getOwnNamespace().index;
|
|
86
|
-
this.nodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeIdType.GUID, (0, node_opcua_basic_types_1.randomGuid)(), ownNamespaceIndex);
|
|
87
|
-
(0, node_opcua_assert_1.assert)(this.authenticationToken instanceof node_opcua_nodeid_1.NodeId);
|
|
88
|
-
(0, node_opcua_assert_1.assert)(this.nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
89
|
-
this._cumulatedSubscriptionCount = 0;
|
|
90
|
-
this.publishEngine = new server_publish_engine_1.ServerSidePublishEngine({
|
|
91
|
-
maxPublishRequestInQueue: ServerSession.maxPublishRequestInQueue
|
|
92
|
-
});
|
|
93
|
-
this.publishEngine.setMaxListeners(100);
|
|
94
|
-
theWatchDog.addSubscriber(this, this.sessionTimeout);
|
|
95
|
-
this.__status = "new";
|
|
96
|
-
/**
|
|
97
|
-
* the continuation point manager for this session
|
|
98
|
-
* @property continuationPointManager
|
|
99
|
-
* @type {ContinuationPointManager}
|
|
100
|
-
*/
|
|
101
|
-
this.continuationPointManager = new node_opcua_address_space_1.ContinuationPointManager();
|
|
102
|
-
/**
|
|
103
|
-
* @property creationDate
|
|
104
|
-
* @type {Date}
|
|
105
|
-
*/
|
|
106
|
-
this.creationDate = new Date();
|
|
107
|
-
this._registeredNodesCounter = 0;
|
|
108
|
-
this._registeredNodes = {};
|
|
109
|
-
this._registeredNodesInv = {};
|
|
110
|
-
}
|
|
111
|
-
getSessionId() {
|
|
112
|
-
return this.nodeId;
|
|
113
|
-
}
|
|
114
|
-
getEndpointDescription() {
|
|
115
|
-
return this.endpoint;
|
|
116
|
-
}
|
|
117
|
-
dispose() {
|
|
118
|
-
debugLog("ServerSession#dispose()");
|
|
119
|
-
(0, node_opcua_assert_1.assert)(!this.sessionObject, " sessionObject has not been cleared !");
|
|
120
|
-
this.parent = null;
|
|
121
|
-
this.authenticationToken = new node_opcua_nodeid_1.NodeId();
|
|
122
|
-
if (this.publishEngine) {
|
|
123
|
-
this.publishEngine.dispose();
|
|
124
|
-
this.publishEngine = null;
|
|
125
|
-
}
|
|
126
|
-
this._sessionDiagnostics = undefined;
|
|
127
|
-
this._registeredNodesCounter = 0;
|
|
128
|
-
this._registeredNodes = null;
|
|
129
|
-
this._registeredNodesInv = null;
|
|
130
|
-
this.continuationPointManager = null;
|
|
131
|
-
this.removeAllListeners();
|
|
132
|
-
this.__status = "disposed";
|
|
133
|
-
ServerSession.registry.unregister(this);
|
|
134
|
-
}
|
|
135
|
-
get clientConnectionTime() {
|
|
136
|
-
return this.creationDate;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* return the number of milisecond since last session transaction occurs from client
|
|
140
|
-
* the first transaction is the creation of the session
|
|
141
|
-
*/
|
|
142
|
-
get clientLastContactTime() {
|
|
143
|
-
const lastSeen = this._watchDogData ? this._watchDogData.lastSeen : node_opcua_basic_types_1.minOPCUADate.getTime();
|
|
144
|
-
return node_opcua_utils_1.WatchDog.lastSeenToDuration(lastSeen);
|
|
145
|
-
}
|
|
146
|
-
get status() {
|
|
147
|
-
return this.__status;
|
|
148
|
-
}
|
|
149
|
-
set status(value) {
|
|
150
|
-
if (value === "active") {
|
|
151
|
-
this._createSessionObjectInAddressSpace();
|
|
152
|
-
}
|
|
153
|
-
if (this.__status !== value) {
|
|
154
|
-
this.emit("statusChanged", value);
|
|
155
|
-
}
|
|
156
|
-
this.__status = value;
|
|
157
|
-
}
|
|
158
|
-
get addressSpace() {
|
|
159
|
-
if (this.parent && this.parent.addressSpace) {
|
|
160
|
-
return this.parent.addressSpace;
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
get currentPublishRequestInQueue() {
|
|
165
|
-
return this.publishEngine ? this.publishEngine.pendingPublishRequestCount : 0;
|
|
166
|
-
}
|
|
167
|
-
updateClientLastContactTime() {
|
|
168
|
-
if (this._sessionDiagnostics && this._sessionDiagnostics.clientLastContactTime) {
|
|
169
|
-
const currentTime = new Date();
|
|
170
|
-
// do not record all ticks as this may be overwhelming,
|
|
171
|
-
if (currentTime.getTime() - 250 >= this._sessionDiagnostics.clientLastContactTime.getTime()) {
|
|
172
|
-
this._sessionDiagnostics.clientLastContactTime = currentTime;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* @method onClientSeen
|
|
178
|
-
* required for watch dog
|
|
179
|
-
* @param currentTime {DateTime}
|
|
180
|
-
* @private
|
|
181
|
-
*/
|
|
182
|
-
onClientSeen() {
|
|
183
|
-
this.updateClientLastContactTime();
|
|
184
|
-
if (this._sessionDiagnostics) {
|
|
185
|
-
// see https://opcfoundation-onlineapplications.org/mantis/view.php?id=4111
|
|
186
|
-
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(this._sessionDiagnostics, "currentMonitoredItemsCount"));
|
|
187
|
-
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(this._sessionDiagnostics, "currentSubscriptionsCount"));
|
|
188
|
-
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(this._sessionDiagnostics, "currentPublishRequestsInQueue"));
|
|
189
|
-
// note : https://opcfoundation-onlineapplications.org/mantis/view.php?id=4111
|
|
190
|
-
// sessionDiagnostics extension object uses a different spelling
|
|
191
|
-
// here with an S !!!!
|
|
192
|
-
if (this._sessionDiagnostics.currentMonitoredItemsCount !== this.currentMonitoredItemCount) {
|
|
193
|
-
this._sessionDiagnostics.currentMonitoredItemsCount = this.currentMonitoredItemCount;
|
|
194
|
-
}
|
|
195
|
-
if (this._sessionDiagnostics.currentSubscriptionsCount !== this.currentSubscriptionCount) {
|
|
196
|
-
this._sessionDiagnostics.currentSubscriptionsCount = this.currentSubscriptionCount;
|
|
197
|
-
}
|
|
198
|
-
if (this._sessionDiagnostics.currentPublishRequestsInQueue !== this.currentPublishRequestInQueue) {
|
|
199
|
-
this._sessionDiagnostics.currentPublishRequestsInQueue = this.currentPublishRequestInQueue;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
incrementTotalRequestCount() {
|
|
204
|
-
if (this._sessionDiagnostics && this._sessionDiagnostics.totalRequestCount) {
|
|
205
|
-
this._sessionDiagnostics.totalRequestCount.totalCount += 1;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
incrementRequestTotalCounter(counterName) {
|
|
209
|
-
if (this._sessionDiagnostics) {
|
|
210
|
-
const propName = (0, node_opcua_utils_2.lowerFirstLetter)(counterName + "Count");
|
|
211
|
-
// istanbul ignore next
|
|
212
|
-
if (!Object.prototype.hasOwnProperty.call(this._sessionDiagnostics, propName)) {
|
|
213
|
-
errorLog("incrementRequestTotalCounter: cannot find", propName);
|
|
214
|
-
// xx return;
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
this._sessionDiagnostics[propName].totalCount += 1;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
incrementRequestErrorCounter(counterName) {
|
|
222
|
-
var _a;
|
|
223
|
-
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.incrementRejectedRequestsCount();
|
|
224
|
-
if (this._sessionDiagnostics) {
|
|
225
|
-
const propName = (0, node_opcua_utils_2.lowerFirstLetter)(counterName + "Count");
|
|
226
|
-
// istanbul ignore next
|
|
227
|
-
if (!Object.prototype.hasOwnProperty.call(this._sessionDiagnostics, propName)) {
|
|
228
|
-
errorLog("incrementRequestErrorCounter: cannot find", propName);
|
|
229
|
-
// xx return;
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
this._sessionDiagnostics[propName].errorCount += 1;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* returns rootFolder.objects.server.serverDiagnostics.sessionsDiagnosticsSummary.sessionDiagnosticsArray
|
|
238
|
-
*/
|
|
239
|
-
getSessionDiagnosticsArray() {
|
|
240
|
-
const server = this.addressSpace.rootFolder.objects.server;
|
|
241
|
-
return server.serverDiagnostics.sessionsDiagnosticsSummary.sessionDiagnosticsArray;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* returns rootFolder.objects.server.serverDiagnostics.sessionsDiagnosticsSummary.sessionSecurityDiagnosticsArray
|
|
245
|
-
*/
|
|
246
|
-
getSessionSecurityDiagnosticsArray() {
|
|
247
|
-
const server = this.addressSpace.rootFolder.objects.server;
|
|
248
|
-
return server.serverDiagnostics.sessionsDiagnosticsSummary.sessionSecurityDiagnosticsArray;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* number of active subscriptions
|
|
252
|
-
*/
|
|
253
|
-
get currentSubscriptionCount() {
|
|
254
|
-
return this.publishEngine ? this.publishEngine.subscriptionCount : 0;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* number of subscriptions ever created since this object is live
|
|
258
|
-
*/
|
|
259
|
-
get cumulatedSubscriptionCount() {
|
|
260
|
-
return this._cumulatedSubscriptionCount;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* number of monitored items
|
|
264
|
-
*/
|
|
265
|
-
get currentMonitoredItemCount() {
|
|
266
|
-
return this.publishEngine ? this.publishEngine.currentMonitoredItemCount : 0;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* retrieve an existing subscription by subscriptionId
|
|
270
|
-
* @method getSubscription
|
|
271
|
-
* @param subscriptionId {Number}
|
|
272
|
-
* @return {Subscription}
|
|
273
|
-
*/
|
|
274
|
-
getSubscription(subscriptionId) {
|
|
275
|
-
const subscription = this.publishEngine.getSubscriptionById(subscriptionId);
|
|
276
|
-
if (subscription && subscription.state === server_subscription_1.SubscriptionState.CLOSED) {
|
|
277
|
-
// subscription is CLOSED but has not been notified yet
|
|
278
|
-
// it should be considered as excluded
|
|
279
|
-
return null;
|
|
280
|
-
}
|
|
281
|
-
(0, node_opcua_assert_1.assert)(!subscription || subscription.state !== server_subscription_1.SubscriptionState.CLOSED, "CLOSED subscription shall not be managed by publish engine anymore");
|
|
282
|
-
return subscription;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* @method deleteSubscription
|
|
286
|
-
* @param subscriptionId {Number}
|
|
287
|
-
* @return {StatusCode}
|
|
288
|
-
*/
|
|
289
|
-
deleteSubscription(subscriptionId) {
|
|
290
|
-
const subscription = this.getSubscription(subscriptionId);
|
|
291
|
-
if (!subscription) {
|
|
292
|
-
return node_opcua_status_code_1.StatusCodes.BadSubscriptionIdInvalid;
|
|
293
|
-
}
|
|
294
|
-
// xx this.publishEngine.remove_subscription(subscription);
|
|
295
|
-
subscription.terminate();
|
|
296
|
-
if (this.currentSubscriptionCount === 0) {
|
|
297
|
-
const local_publishEngine = this.publishEngine;
|
|
298
|
-
local_publishEngine.cancelPendingPublishRequest();
|
|
299
|
-
}
|
|
300
|
-
return node_opcua_status_code_1.StatusCodes.Good;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* close a ServerSession, this will also delete the subscriptions if the flag is set.
|
|
304
|
-
*
|
|
305
|
-
* Spec extract:
|
|
306
|
-
*
|
|
307
|
-
* If a Client invokes the CloseSession Service then all Subscriptions associated with the Session are also deleted
|
|
308
|
-
* if the deleteSubscriptions flag is set to TRUE. If a Server terminates a Session for any other reason,
|
|
309
|
-
* Subscriptions associated with the Session, are not deleted. Each Subscription has its own lifetime to protect
|
|
310
|
-
* against data loss in the case of a Session termination. In these cases, the Subscription can be reassigned to
|
|
311
|
-
* another Client before its lifetime expires.
|
|
312
|
-
*
|
|
313
|
-
* @method close
|
|
314
|
-
* @param deleteSubscriptions : should we delete subscription ?
|
|
315
|
-
* @param [reason = "CloseSession"] the reason for closing the session
|
|
316
|
-
* (shall be "Timeout", "Terminated" or "CloseSession")
|
|
317
|
-
*
|
|
318
|
-
*/
|
|
319
|
-
close(deleteSubscriptions, reason) {
|
|
320
|
-
debugLog(" closing session deleteSubscriptions = ", deleteSubscriptions);
|
|
321
|
-
if (this.publishEngine) {
|
|
322
|
-
this.publishEngine.onSessionClose();
|
|
323
|
-
}
|
|
324
|
-
theWatchDog.removeSubscriber(this);
|
|
325
|
-
// --------------- delete associated subscriptions ---------------------
|
|
326
|
-
if (!deleteSubscriptions && this.currentSubscriptionCount !== 0) {
|
|
327
|
-
// I don't know what to do yet if deleteSubscriptions is false
|
|
328
|
-
errorLog("TO DO : Closing session without deleting subscription not yet implemented");
|
|
329
|
-
// to do: Put subscriptions in safe place for future transfer if any
|
|
330
|
-
}
|
|
331
|
-
this._deleteSubscriptions();
|
|
332
|
-
(0, node_opcua_assert_1.assert)(this.currentSubscriptionCount === 0);
|
|
333
|
-
// Post-Conditions
|
|
334
|
-
(0, node_opcua_assert_1.assert)(this.currentSubscriptionCount === 0);
|
|
335
|
-
this.status = "closed";
|
|
336
|
-
this._detach_channel();
|
|
337
|
-
/**
|
|
338
|
-
* @event session_closed
|
|
339
|
-
* @param deleteSubscriptions {Boolean}
|
|
340
|
-
* @param reason {String}
|
|
341
|
-
*/
|
|
342
|
-
this.emit("session_closed", this, deleteSubscriptions, reason);
|
|
343
|
-
// ---------------- shut down publish engine
|
|
344
|
-
if (this.publishEngine) {
|
|
345
|
-
// remove subscription
|
|
346
|
-
this.publishEngine.shutdown();
|
|
347
|
-
(0, node_opcua_assert_1.assert)(this.publishEngine.subscriptionCount === 0);
|
|
348
|
-
this.publishEngine.dispose();
|
|
349
|
-
this.publishEngine = null;
|
|
350
|
-
}
|
|
351
|
-
this._removeSessionObjectFromAddressSpace();
|
|
352
|
-
(0, node_opcua_assert_1.assert)(!this.sessionDiagnostics, "ServerSession#_removeSessionObjectFromAddressSpace must be called");
|
|
353
|
-
(0, node_opcua_assert_1.assert)(!this.sessionObject, "ServerSession#_removeSessionObjectFromAddressSpace must be called");
|
|
354
|
-
}
|
|
355
|
-
registerNode(nodeId) {
|
|
356
|
-
(0, node_opcua_assert_1.assert)(nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
357
|
-
if (nodeId.namespace === 0 && nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.NUMERIC) {
|
|
358
|
-
return nodeId;
|
|
359
|
-
}
|
|
360
|
-
const key = nodeId.toString();
|
|
361
|
-
const registeredNode = this._registeredNodes[key];
|
|
362
|
-
if (registeredNode) {
|
|
363
|
-
// already registered
|
|
364
|
-
return registeredNode;
|
|
365
|
-
}
|
|
366
|
-
const node = this.addressSpace.findNode(nodeId);
|
|
367
|
-
if (!node) {
|
|
368
|
-
return nodeId;
|
|
369
|
-
}
|
|
370
|
-
this._registeredNodesCounter += 1;
|
|
371
|
-
const aliasNodeId = (0, node_opcua_nodeid_1.makeNodeId)(this._registeredNodesCounter, registeredNodeNameSpace);
|
|
372
|
-
this._registeredNodes[key] = aliasNodeId;
|
|
373
|
-
this._registeredNodesInv[aliasNodeId.toString()] = node;
|
|
374
|
-
return aliasNodeId;
|
|
375
|
-
}
|
|
376
|
-
unRegisterNode(aliasNodeId) {
|
|
377
|
-
(0, node_opcua_assert_1.assert)(aliasNodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
378
|
-
if (aliasNodeId.namespace !== registeredNodeNameSpace) {
|
|
379
|
-
return; // not a registered Node
|
|
380
|
-
}
|
|
381
|
-
const node = this._registeredNodesInv[aliasNodeId.toString()];
|
|
382
|
-
if (!node) {
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
this._registeredNodesInv[aliasNodeId.toString()] = null;
|
|
386
|
-
this._registeredNodes[node.nodeId.toString()] = null;
|
|
387
|
-
}
|
|
388
|
-
resolveRegisteredNode(aliasNodeId) {
|
|
389
|
-
if (aliasNodeId.namespace !== registeredNodeNameSpace) {
|
|
390
|
-
return aliasNodeId; // not a registered Node
|
|
391
|
-
}
|
|
392
|
-
const node = this._registeredNodesInv[aliasNodeId.toString()];
|
|
393
|
-
if (!node) {
|
|
394
|
-
return aliasNodeId;
|
|
395
|
-
}
|
|
396
|
-
return node.nodeId;
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* true if the underlying channel has been closed or aborted...
|
|
400
|
-
*/
|
|
401
|
-
get aborted() {
|
|
402
|
-
if (!this.channel) {
|
|
403
|
-
return true;
|
|
404
|
-
}
|
|
405
|
-
return this.channel.aborted;
|
|
406
|
-
}
|
|
407
|
-
createSubscription(parameters) {
|
|
408
|
-
const subscription = this.parent._createSubscriptionOnSession(this, parameters);
|
|
409
|
-
(0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(parameters, "id"));
|
|
410
|
-
this.assignSubscription(subscription);
|
|
411
|
-
(0, node_opcua_assert_1.assert)(subscription.$session === this);
|
|
412
|
-
(0, node_opcua_assert_1.assert)(subscription.sessionId instanceof node_opcua_nodeid_1.NodeId);
|
|
413
|
-
(0, node_opcua_assert_1.assert)((0, node_opcua_nodeid_1.sameNodeId)(subscription.sessionId, this.nodeId));
|
|
414
|
-
return subscription;
|
|
415
|
-
}
|
|
416
|
-
_attach_channel(channel) {
|
|
417
|
-
(0, node_opcua_assert_1.assert)(this.nonce && this.nonce instanceof Buffer);
|
|
418
|
-
this.channel = channel;
|
|
419
|
-
this.channelId = channel.channelId;
|
|
420
|
-
const key = this.authenticationToken.toString();
|
|
421
|
-
(0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(channel.sessionTokens, key), "channel has already a session");
|
|
422
|
-
channel.sessionTokens[key] = this;
|
|
423
|
-
// when channel is aborting
|
|
424
|
-
this.channel_abort_event_handler = on_channel_abort.bind(this);
|
|
425
|
-
channel.on("abort", this.channel_abort_event_handler);
|
|
426
|
-
}
|
|
427
|
-
_detach_channel() {
|
|
428
|
-
const channel = this.channel;
|
|
429
|
-
// istanbul ignore next
|
|
430
|
-
if (!channel) {
|
|
431
|
-
return;
|
|
432
|
-
// already detached !
|
|
433
|
-
// throw new Error("expecting a valid channel");
|
|
434
|
-
}
|
|
435
|
-
(0, node_opcua_assert_1.assert)(this.nonce && this.nonce instanceof Buffer);
|
|
436
|
-
(0, node_opcua_assert_1.assert)(this.authenticationToken);
|
|
437
|
-
const key = this.authenticationToken.toString();
|
|
438
|
-
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(channel.sessionTokens, key));
|
|
439
|
-
(0, node_opcua_assert_1.assert)(this.channel);
|
|
440
|
-
(0, node_opcua_assert_1.assert)(typeof this.channel_abort_event_handler === "function");
|
|
441
|
-
channel.removeListener("abort", this.channel_abort_event_handler);
|
|
442
|
-
delete channel.sessionTokens[key];
|
|
443
|
-
this.channel = undefined;
|
|
444
|
-
this.channelId = undefined;
|
|
445
|
-
}
|
|
446
|
-
_exposeSubscriptionDiagnostics(subscription) {
|
|
447
|
-
debugLog("ServerSession#_exposeSubscriptionDiagnostics");
|
|
448
|
-
(0, node_opcua_assert_1.assert)(subscription.$session === this);
|
|
449
|
-
const subscriptionDiagnosticsArray = this._getSubscriptionDiagnosticsArray();
|
|
450
|
-
const subscriptionDiagnostics = subscription.subscriptionDiagnostics;
|
|
451
|
-
(0, node_opcua_assert_1.assert)(subscriptionDiagnostics.$subscription === subscription);
|
|
452
|
-
if (subscriptionDiagnostics && subscriptionDiagnosticsArray) {
|
|
453
|
-
// subscription.id,"on session", session.nodeId.toString());
|
|
454
|
-
(0, node_opcua_address_space_1.addElement)(subscriptionDiagnostics, subscriptionDiagnosticsArray);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
_unexposeSubscriptionDiagnostics(subscription) {
|
|
458
|
-
const subscriptionDiagnosticsArray = this._getSubscriptionDiagnosticsArray();
|
|
459
|
-
const subscriptionDiagnostics = subscription.subscriptionDiagnostics;
|
|
460
|
-
(0, node_opcua_assert_1.assert)(subscriptionDiagnostics instanceof node_opcua_common_1.SubscriptionDiagnosticsDataType);
|
|
461
|
-
if (subscriptionDiagnostics && subscriptionDiagnosticsArray) {
|
|
462
|
-
// subscription.id,"on session", session.nodeId.toString());
|
|
463
|
-
(0, node_opcua_address_space_1.removeElement)(subscriptionDiagnosticsArray, (a) => a.subscriptionId === subscription.id);
|
|
464
|
-
}
|
|
465
|
-
debugLog("ServerSession#_unexposeSubscriptionDiagnostics");
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* @method watchdogReset
|
|
469
|
-
* used as a callback for the Watchdog
|
|
470
|
-
* @private
|
|
471
|
-
*/
|
|
472
|
-
watchdogReset() {
|
|
473
|
-
debugLog("Session#watchdogReset: the server session has expired and must be removed from the server");
|
|
474
|
-
// the server session has expired and must be removed from the server
|
|
475
|
-
this.emit("timeout");
|
|
476
|
-
}
|
|
477
|
-
_createSessionObjectInAddressSpace() {
|
|
478
|
-
if (this.sessionObject) {
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
481
|
-
(0, node_opcua_assert_1.assert)(!this.sessionObject, "ServerSession#_createSessionObjectInAddressSpace already called ?");
|
|
482
|
-
this.sessionObject = null;
|
|
483
|
-
if (!this.addressSpace) {
|
|
484
|
-
debugLog("ServerSession#_createSessionObjectInAddressSpace : no addressSpace");
|
|
485
|
-
return; // no addressSpace
|
|
486
|
-
}
|
|
487
|
-
const root = this.addressSpace.rootFolder;
|
|
488
|
-
(0, node_opcua_assert_1.assert)(root, "expecting a root object");
|
|
489
|
-
if (!root.objects) {
|
|
490
|
-
debugLog("ServerSession#_createSessionObjectInAddressSpace : no object folder");
|
|
491
|
-
return false;
|
|
492
|
-
}
|
|
493
|
-
if (!root.objects.server) {
|
|
494
|
-
debugLog("ServerSession#_createSessionObjectInAddressSpace : no server object");
|
|
495
|
-
return false;
|
|
496
|
-
}
|
|
497
|
-
// self.addressSpace.findNode(makeNodeId(ObjectIds.Server_ServerDiagnostics));
|
|
498
|
-
const serverDiagnosticsNode = root.objects.server.serverDiagnostics;
|
|
499
|
-
if (!serverDiagnosticsNode || !serverDiagnosticsNode.sessionsDiagnosticsSummary) {
|
|
500
|
-
debugLog("ServerSession#_createSessionObjectInAddressSpace :" + " no serverDiagnostics.sessionsDiagnosticsSummary");
|
|
501
|
-
return false;
|
|
502
|
-
}
|
|
503
|
-
const sessionDiagnosticsObjectType = this.addressSpace.findObjectType("SessionDiagnosticsObjectType");
|
|
504
|
-
const sessionDiagnosticsDataType = this.addressSpace.findDataType("SessionDiagnosticsDataType");
|
|
505
|
-
const sessionDiagnosticsVariableType = this.addressSpace.findVariableType("SessionDiagnosticsVariableType");
|
|
506
|
-
const sessionSecurityDiagnosticsDataType = this.addressSpace.findDataType("SessionSecurityDiagnosticsDataType");
|
|
507
|
-
const sessionSecurityDiagnosticsType = this.addressSpace.findVariableType("SessionSecurityDiagnosticsType");
|
|
508
|
-
const namespace = this.addressSpace.getOwnNamespace();
|
|
509
|
-
function createSessionDiagnosticsStuff() {
|
|
510
|
-
if (sessionDiagnosticsDataType && sessionDiagnosticsVariableType) {
|
|
511
|
-
// the extension object
|
|
512
|
-
this._sessionDiagnostics = this.addressSpace.constructExtensionObject(sessionDiagnosticsDataType, {});
|
|
513
|
-
this._sessionDiagnostics.$session = this;
|
|
514
|
-
// install property getter on property that are unlikely to change
|
|
515
|
-
if (this.parent.clientDescription) {
|
|
516
|
-
this._sessionDiagnostics.clientDescription = this.parent.clientDescription;
|
|
517
|
-
}
|
|
518
|
-
Object.defineProperty(this._sessionDiagnostics, "clientConnectionTime", {
|
|
519
|
-
get() {
|
|
520
|
-
return this.$session.clientConnectionTime;
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
Object.defineProperty(this._sessionDiagnostics, "actualSessionTimeout", {
|
|
524
|
-
get() {
|
|
525
|
-
var _a;
|
|
526
|
-
return (_a = this.$session) === null || _a === void 0 ? void 0 : _a.sessionTimeout;
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
Object.defineProperty(this._sessionDiagnostics, "sessionId", {
|
|
530
|
-
get() {
|
|
531
|
-
return this.$session ? this.$session.nodeId : node_opcua_nodeid_1.NodeId.nullNodeId;
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
Object.defineProperty(this._sessionDiagnostics, "sessionName", {
|
|
535
|
-
get() {
|
|
536
|
-
return this.$session ? this.$session.sessionName.toString() : "";
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
this.sessionDiagnostics = sessionDiagnosticsVariableType.instantiate({
|
|
540
|
-
browseName: new node_opcua_data_model_1.QualifiedName({ name: "SessionDiagnostics", namespaceIndex: 0 }),
|
|
541
|
-
componentOf: this.sessionObject,
|
|
542
|
-
extensionObject: this._sessionDiagnostics,
|
|
543
|
-
minimumSamplingInterval: 2000 // 2 seconds
|
|
544
|
-
});
|
|
545
|
-
this._sessionDiagnostics = this.sessionDiagnostics.$extensionObject;
|
|
546
|
-
(0, node_opcua_assert_1.assert)(this._sessionDiagnostics.$session === this);
|
|
547
|
-
const sessionDiagnosticsArray = this.getSessionDiagnosticsArray();
|
|
548
|
-
// add sessionDiagnostics into sessionDiagnosticsArray
|
|
549
|
-
(0, node_opcua_address_space_1.addElement)(this._sessionDiagnostics, sessionDiagnosticsArray);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
function createSessionSecurityDiagnosticsStuff() {
|
|
553
|
-
if (sessionSecurityDiagnosticsDataType && sessionSecurityDiagnosticsType) {
|
|
554
|
-
// the extension object
|
|
555
|
-
this._sessionSecurityDiagnostics = this.addressSpace.constructExtensionObject(sessionSecurityDiagnosticsDataType, {});
|
|
556
|
-
this._sessionSecurityDiagnostics.$session = this;
|
|
557
|
-
/*
|
|
558
|
-
sessionId: NodeId;
|
|
559
|
-
clientUserIdOfSession: UAString;
|
|
560
|
-
clientUserIdHistory: UAString[] | null;
|
|
561
|
-
authenticationMechanism: UAString;
|
|
562
|
-
encoding: UAString;
|
|
563
|
-
transportProtocol: UAString;
|
|
564
|
-
securityMode: MessageSecurityMode;
|
|
565
|
-
securityPolicyUri: UAString;
|
|
566
|
-
clientCertificate: ByteString;
|
|
567
|
-
*/
|
|
568
|
-
Object.defineProperty(this._sessionSecurityDiagnostics, "sessionId", {
|
|
569
|
-
get() {
|
|
570
|
-
var _a;
|
|
571
|
-
return (_a = this.$session) === null || _a === void 0 ? void 0 : _a.nodeId;
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
Object.defineProperty(this._sessionSecurityDiagnostics, "clientUserIdOfSession", {
|
|
575
|
-
get() {
|
|
576
|
-
return ""; // UAString // TO DO : implement
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
Object.defineProperty(this._sessionSecurityDiagnostics, "clientUserIdHistory", {
|
|
580
|
-
get() {
|
|
581
|
-
return []; // UAString[] | null
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
Object.defineProperty(this._sessionSecurityDiagnostics, "authenticationMechanism", {
|
|
585
|
-
get() {
|
|
586
|
-
return "";
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
Object.defineProperty(this._sessionSecurityDiagnostics, "encoding", {
|
|
590
|
-
get() {
|
|
591
|
-
return "";
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
Object.defineProperty(this._sessionSecurityDiagnostics, "transportProtocol", {
|
|
595
|
-
get() {
|
|
596
|
-
return "opc.tcp";
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
Object.defineProperty(this._sessionSecurityDiagnostics, "securityMode", {
|
|
600
|
-
get() {
|
|
601
|
-
var _a;
|
|
602
|
-
const session = this.$session;
|
|
603
|
-
return (_a = session === null || session === void 0 ? void 0 : session.channel) === null || _a === void 0 ? void 0 : _a.securityMode;
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
Object.defineProperty(this._sessionSecurityDiagnostics, "securityPolicyUri", {
|
|
607
|
-
get() {
|
|
608
|
-
var _a;
|
|
609
|
-
const session = this.$session;
|
|
610
|
-
return (_a = session === null || session === void 0 ? void 0 : session.channel) === null || _a === void 0 ? void 0 : _a.securityPolicy;
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
Object.defineProperty(this._sessionSecurityDiagnostics, "clientCertificate", {
|
|
614
|
-
get() {
|
|
615
|
-
const session = this.$session;
|
|
616
|
-
return session === null || session === void 0 ? void 0 : session.channel.clientCertificate;
|
|
617
|
-
}
|
|
618
|
-
});
|
|
619
|
-
this.sessionSecurityDiagnostics = sessionSecurityDiagnosticsType.instantiate({
|
|
620
|
-
browseName: new node_opcua_data_model_1.QualifiedName({ name: "SessionSecurityDiagnostics", namespaceIndex: 0 }),
|
|
621
|
-
componentOf: this.sessionObject,
|
|
622
|
-
extensionObject: this._sessionSecurityDiagnostics,
|
|
623
|
-
minimumSamplingInterval: 2000 // 2 seconds
|
|
624
|
-
});
|
|
625
|
-
(0, node_opcua_address_space_1.ensureObjectIsSecure)(this.sessionSecurityDiagnostics);
|
|
626
|
-
this._sessionSecurityDiagnostics = this.sessionSecurityDiagnostics
|
|
627
|
-
.$extensionObject;
|
|
628
|
-
(0, node_opcua_assert_1.assert)(this._sessionSecurityDiagnostics.$session === this);
|
|
629
|
-
const sessionSecurityDiagnosticsArray = this.getSessionSecurityDiagnosticsArray();
|
|
630
|
-
// add sessionDiagnostics into sessionDiagnosticsArray
|
|
631
|
-
const node = (0, node_opcua_address_space_1.addElement)(this._sessionSecurityDiagnostics, sessionSecurityDiagnosticsArray);
|
|
632
|
-
(0, node_opcua_address_space_1.ensureObjectIsSecure)(node);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
function createSessionDiagnosticSummaryUAObject() {
|
|
636
|
-
const references = [];
|
|
637
|
-
if (sessionDiagnosticsObjectType) {
|
|
638
|
-
references.push({
|
|
639
|
-
isForward: true,
|
|
640
|
-
nodeId: sessionDiagnosticsObjectType,
|
|
641
|
-
referenceType: "HasTypeDefinition"
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
this.sessionObject = namespace.createNode({
|
|
645
|
-
browseName: this.sessionName || "Session-" + this.nodeId.toString(),
|
|
646
|
-
componentOf: serverDiagnosticsNode.sessionsDiagnosticsSummary,
|
|
647
|
-
nodeClass: node_opcua_data_model_1.NodeClass.Object,
|
|
648
|
-
nodeId: this.nodeId,
|
|
649
|
-
references,
|
|
650
|
-
typeDefinition: sessionDiagnosticsObjectType
|
|
651
|
-
});
|
|
652
|
-
createSessionDiagnosticsStuff.call(this);
|
|
653
|
-
createSessionSecurityDiagnosticsStuff.call(this);
|
|
654
|
-
}
|
|
655
|
-
function createSubscriptionDiagnosticsArray() {
|
|
656
|
-
const subscriptionDiagnosticsArrayType = this.addressSpace.findVariableType("SubscriptionDiagnosticsArrayType");
|
|
657
|
-
(0, node_opcua_assert_1.assert)(subscriptionDiagnosticsArrayType.nodeId.toString() === "ns=0;i=2171");
|
|
658
|
-
this.subscriptionDiagnosticsArray = (0, node_opcua_address_space_1.createExtObjArrayNode)(this.sessionObject, {
|
|
659
|
-
browseName: { namespaceIndex: 0, name: "SubscriptionDiagnosticsArray" },
|
|
660
|
-
complexVariableType: "SubscriptionDiagnosticsArrayType",
|
|
661
|
-
indexPropertyName: "subscriptionId",
|
|
662
|
-
minimumSamplingInterval: 2000,
|
|
663
|
-
variableType: "SubscriptionDiagnosticsType"
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
createSessionDiagnosticSummaryUAObject.call(this);
|
|
667
|
-
createSubscriptionDiagnosticsArray.call(this);
|
|
668
|
-
return this.sessionObject;
|
|
669
|
-
}
|
|
670
|
-
resendMonitoredItemInitialValues() {
|
|
671
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
672
|
-
for (const subscription of this.publishEngine.subscriptions) {
|
|
673
|
-
yield subscription.resendInitialValues();
|
|
674
|
-
}
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
*
|
|
679
|
-
* @private
|
|
680
|
-
*/
|
|
681
|
-
_removeSessionObjectFromAddressSpace() {
|
|
682
|
-
// todo : dump session statistics in a file or somewhere for deeper diagnostic analysis on closed session
|
|
683
|
-
if (!this.addressSpace) {
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
if (this.sessionDiagnostics) {
|
|
687
|
-
const sessionDiagnosticsArray = this.getSessionDiagnosticsArray();
|
|
688
|
-
(0, node_opcua_address_space_1.removeElement)(sessionDiagnosticsArray, (a) => (0, node_opcua_nodeid_1.sameNodeId)(a.sessionId, this.getSessionId()));
|
|
689
|
-
this.addressSpace.deleteNode(this.sessionDiagnostics);
|
|
690
|
-
(0, node_opcua_assert_1.assert)(this._sessionDiagnostics.$session === this);
|
|
691
|
-
this._sessionDiagnostics.$session = null;
|
|
692
|
-
this._sessionDiagnostics = undefined;
|
|
693
|
-
this.sessionDiagnostics = undefined;
|
|
694
|
-
}
|
|
695
|
-
if (this.sessionSecurityDiagnostics) {
|
|
696
|
-
const sessionSecurityDiagnosticsArray = this.getSessionSecurityDiagnosticsArray();
|
|
697
|
-
(0, node_opcua_address_space_1.removeElement)(sessionSecurityDiagnosticsArray, (a) => (0, node_opcua_nodeid_1.sameNodeId)(a.sessionId, this.getSessionId()));
|
|
698
|
-
this.addressSpace.deleteNode(this.sessionSecurityDiagnostics);
|
|
699
|
-
(0, node_opcua_assert_1.assert)(this._sessionSecurityDiagnostics.$session === this);
|
|
700
|
-
this._sessionSecurityDiagnostics.$session = null;
|
|
701
|
-
this._sessionSecurityDiagnostics = undefined;
|
|
702
|
-
this.sessionSecurityDiagnostics = undefined;
|
|
703
|
-
}
|
|
704
|
-
if (this.sessionObject) {
|
|
705
|
-
this.addressSpace.deleteNode(this.sessionObject);
|
|
706
|
-
this.sessionObject = null;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
*
|
|
711
|
-
* @private
|
|
712
|
-
*/
|
|
713
|
-
_getSubscriptionDiagnosticsArray() {
|
|
714
|
-
if (!this.addressSpace) {
|
|
715
|
-
if (doDebug) {
|
|
716
|
-
console.warn("ServerSession#_getSubscriptionDiagnosticsArray : no addressSpace");
|
|
717
|
-
}
|
|
718
|
-
return null; // no addressSpace
|
|
719
|
-
}
|
|
720
|
-
const subscriptionDiagnosticsArray = this.subscriptionDiagnosticsArray;
|
|
721
|
-
if (!subscriptionDiagnosticsArray) {
|
|
722
|
-
return null; // no subscriptionDiagnosticsArray
|
|
723
|
-
}
|
|
724
|
-
(0, node_opcua_assert_1.assert)(subscriptionDiagnosticsArray.browseName.toString() === "SubscriptionDiagnosticsArray");
|
|
725
|
-
return subscriptionDiagnosticsArray;
|
|
726
|
-
}
|
|
727
|
-
assignSubscription(subscription) {
|
|
728
|
-
(0, node_opcua_assert_1.assert)(!subscription.$session);
|
|
729
|
-
(0, node_opcua_assert_1.assert)(this.nodeId instanceof node_opcua_nodeid_1.NodeId);
|
|
730
|
-
subscription.$session = this;
|
|
731
|
-
(0, node_opcua_assert_1.assert)(subscription.sessionId === this.nodeId);
|
|
732
|
-
this._cumulatedSubscriptionCount += 1;
|
|
733
|
-
// Notify the owner that a new subscription has been created
|
|
734
|
-
// @event new_subscription
|
|
735
|
-
// @param {Subscription} subscription
|
|
736
|
-
this.emit("new_subscription", subscription);
|
|
737
|
-
// add subscription diagnostics to SubscriptionDiagnosticsArray
|
|
738
|
-
this._exposeSubscriptionDiagnostics(subscription);
|
|
739
|
-
subscription.once("terminated", () => {
|
|
740
|
-
// Notify the owner that a new subscription has been terminated
|
|
741
|
-
// @event subscription_terminated
|
|
742
|
-
// @param {Subscription} subscription
|
|
743
|
-
this.emit("subscription_terminated", subscription);
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
_deleteSubscriptions() {
|
|
747
|
-
if (!this.publishEngine)
|
|
748
|
-
return;
|
|
749
|
-
const subscriptions = this.publishEngine.subscriptions;
|
|
750
|
-
for (const subscription of subscriptions) {
|
|
751
|
-
this.deleteSubscription(subscription.id);
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
exports.ServerSession = ServerSession;
|
|
756
|
-
ServerSession.registry = new node_opcua_object_registry_1.ObjectRegistry();
|
|
757
|
-
ServerSession.maxPublishRequestInQueue = 100;
|
|
758
|
-
//# sourceMappingURL=server_session.js.map
|