node-opcua-client 2.132.0 → 2.133.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/client_base.d.ts +5 -19
- package/dist/client_base.js.map +1 -1
- package/dist/client_session.d.ts +10 -75
- package/dist/client_session.js.map +1 -1
- package/dist/client_session_keepalive_manager.d.ts +1 -3
- package/dist/client_session_keepalive_manager.js +1 -3
- package/dist/client_session_keepalive_manager.js.map +1 -1
- package/dist/client_subscription.d.ts +0 -9
- package/dist/client_subscription.js.map +1 -1
- package/dist/client_utils.d.ts +1 -4
- package/dist/client_utils.js +1 -4
- package/dist/client_utils.js.map +1 -1
- package/dist/private/client_base_impl.d.ts +3 -4
- package/dist/private/client_base_impl.js +2 -2
- package/dist/private/client_base_impl.js.map +1 -1
- package/dist/private/client_monitored_item_group_impl.d.ts +2 -4
- package/dist/private/client_monitored_item_group_impl.js +1 -1
- package/dist/private/client_monitored_item_group_impl.js.map +1 -1
- package/dist/private/client_monitored_item_impl.d.ts +5 -6
- package/dist/private/client_monitored_item_impl.js +4 -4
- package/dist/private/client_monitored_item_impl.js.map +1 -1
- package/dist/private/client_publish_engine.d.ts +12 -6
- package/dist/private/client_publish_engine.js +12 -6
- package/dist/private/client_publish_engine.js.map +1 -1
- package/dist/private/client_session_impl.d.ts +11 -76
- package/dist/private/client_session_impl.js +7 -32
- package/dist/private/client_session_impl.js.map +1 -1
- package/dist/private/client_subscription_impl.d.ts +1 -1
- package/dist/private/client_subscription_impl.js +1 -1
- package/dist/private/opcua_client_impl.d.ts +2 -8
- package/dist/private/opcua_client_impl.js +2 -8
- package/dist/private/opcua_client_impl.js.map +1 -1
- package/dist/private/reconnection/client_subscription_reconnection.d.ts +1 -1
- package/dist/private/reconnection/client_subscription_reconnection.js +1 -1
- package/dist/tools/findservers.d.ts +0 -4
- package/dist/tools/findservers.js.map +1 -1
- package/package.json +42 -42
- package/source/client_base.ts +7 -19
- package/source/client_session.ts +19 -89
- package/source/client_session_keepalive_manager.ts +1 -3
- package/source/client_subscription.ts +0 -9
- package/source/client_utils.ts +1 -4
- package/source/private/client_base_impl.ts +3 -4
- package/source/private/client_monitored_item_group_impl.ts +2 -4
- package/source/private/client_monitored_item_impl.ts +5 -6
- package/source/private/client_publish_engine.ts +12 -6
- package/source/private/client_session_impl.ts +48 -101
- package/source/private/client_subscription_impl.ts +1 -1
- package/source/private/opcua_client_impl.ts +5 -16
- package/source/private/reconnection/client_subscription_reconnection.ts +1 -1
- package/source/tools/findservers.ts +0 -4
|
@@ -90,13 +90,11 @@ export class ClientSessionKeepAliveManager extends EventEmitter implements Clien
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
* @
|
|
94
|
-
* @internal
|
|
93
|
+
* @private
|
|
95
94
|
* when a session is opened on a server, the client shall send request on a regular basis otherwise the server
|
|
96
95
|
* session object might time out.
|
|
97
96
|
* start_ping make sure that ping_server is called on a regular basis to prevent session to timeout.
|
|
98
97
|
*
|
|
99
|
-
* @param callback
|
|
100
98
|
*/
|
|
101
99
|
private async _ping_server(): Promise<number> {
|
|
102
100
|
const session = this.session;
|
|
@@ -82,7 +82,6 @@ export interface ClientSubscription extends EventEmitter {
|
|
|
82
82
|
/**
|
|
83
83
|
* add a monitor item to the subscription
|
|
84
84
|
*
|
|
85
|
-
* @method monitor
|
|
86
85
|
*
|
|
87
86
|
* Monitoring a simple Value Change
|
|
88
87
|
* ---------------------------------
|
|
@@ -193,12 +192,10 @@ export interface ClientSubscription extends EventEmitter {
|
|
|
193
192
|
): void;
|
|
194
193
|
|
|
195
194
|
/**
|
|
196
|
-
* @method monitorItems
|
|
197
195
|
* @param itemsToMonitor
|
|
198
196
|
* @param requestedParameters
|
|
199
197
|
* @param timestampsToReturn
|
|
200
198
|
* @return a ClientMonitoredItemGroup
|
|
201
|
-
* @async
|
|
202
199
|
*/
|
|
203
200
|
monitorItems(
|
|
204
201
|
itemsToMonitor: ReadValueIdOptions[],
|
|
@@ -207,12 +204,6 @@ export interface ClientSubscription extends EventEmitter {
|
|
|
207
204
|
): Promise<ClientMonitoredItemGroup>;
|
|
208
205
|
|
|
209
206
|
/**
|
|
210
|
-
* @method monitorItems
|
|
211
|
-
* @param itemsToMonitor
|
|
212
|
-
* @param requestedParameters
|
|
213
|
-
* @param timestampsToReturn
|
|
214
|
-
* @param done
|
|
215
|
-
* @async
|
|
216
207
|
*/
|
|
217
208
|
monitorItems(
|
|
218
209
|
itemsToMonitor: ReadValueIdOptions[],
|
package/source/client_utils.ts
CHANGED
|
@@ -39,10 +39,7 @@ interface AnalogDataItemSnapshot {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param session
|
|
44
|
-
* @param nodeId
|
|
45
|
-
* @param callback
|
|
42
|
+
*
|
|
46
43
|
*/
|
|
47
44
|
export async function readUAAnalogItem(
|
|
48
45
|
session: IBasicSessionTranslateBrowsePathAsyncMultiple & IBasicSessionReadAsyncMultiple,
|
|
@@ -871,7 +871,6 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
871
871
|
|
|
872
872
|
/**
|
|
873
873
|
* connect the OPC-UA client to a server end point.
|
|
874
|
-
* @async
|
|
875
874
|
*/
|
|
876
875
|
public connect(endpointUrl: string): Promise<void>;
|
|
877
876
|
public connect(endpointUrl: string, callback: ErrorCallback): void;
|
|
@@ -1019,7 +1018,7 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
1019
1018
|
/**
|
|
1020
1019
|
*
|
|
1021
1020
|
* return the endpoint information matching security mode and security policy.
|
|
1022
|
-
|
|
1021
|
+
|
|
1023
1022
|
*/
|
|
1024
1023
|
public findEndpointForSecurity(
|
|
1025
1024
|
securityMode: MessageSecurityMode,
|
|
@@ -1036,7 +1035,7 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
1036
1035
|
/**
|
|
1037
1036
|
*
|
|
1038
1037
|
* return the endpoint information matching the specified url , security mode and security policy.
|
|
1039
|
-
|
|
1038
|
+
|
|
1040
1039
|
*/
|
|
1041
1040
|
public findEndpoint(
|
|
1042
1041
|
endpointUrl: string,
|
|
@@ -1104,7 +1103,7 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
1104
1103
|
}
|
|
1105
1104
|
|
|
1106
1105
|
/**
|
|
1107
|
-
|
|
1106
|
+
|
|
1108
1107
|
*/
|
|
1109
1108
|
public findServers(options?: FindServersRequestLike): Promise<ApplicationDescription[]>;
|
|
1110
1109
|
public findServers(options: FindServersRequestLike, callback: ResponseCallback<ApplicationDescription[]>): void;
|
|
@@ -90,9 +90,7 @@ export class ClientMonitoredItemGroupImpl extends EventEmitter implements Client
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* @method terminate
|
|
94
93
|
* remove the MonitoredItem from its subscription
|
|
95
|
-
* @async
|
|
96
94
|
*/
|
|
97
95
|
public async terminate(): Promise<void>;
|
|
98
96
|
public terminate(done: ErrorCallback): void;
|
|
@@ -111,7 +109,7 @@ export class ClientMonitoredItemGroupImpl extends EventEmitter implements Client
|
|
|
111
109
|
|
|
112
110
|
// tslint:disable:unified-signatures
|
|
113
111
|
/**
|
|
114
|
-
|
|
112
|
+
|
|
115
113
|
*/
|
|
116
114
|
public async modify(parameters: MonitoringParametersOptions): Promise<StatusCode>;
|
|
117
115
|
public async modify(parameters: MonitoringParametersOptions, timestampsToReturn: TimestampsToReturn): Promise<StatusCode>;
|
|
@@ -158,7 +156,7 @@ export class ClientMonitoredItemGroupImpl extends EventEmitter implements Client
|
|
|
158
156
|
|
|
159
157
|
/**
|
|
160
158
|
* @internal
|
|
161
|
-
|
|
159
|
+
|
|
162
160
|
* Creates the monitor item (monitoring mode = Reporting)
|
|
163
161
|
* @private
|
|
164
162
|
*/
|
|
@@ -46,10 +46,10 @@ export type PrepareForMonitoringResult =
|
|
|
46
46
|
* @class ClientMonitoredItem
|
|
47
47
|
* @extends ClientMonitoredItemBase
|
|
48
48
|
*
|
|
49
|
-
* event:
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
49
|
+
* - event:
|
|
50
|
+
* - "initialized"
|
|
51
|
+
* - "err"
|
|
52
|
+
* - "changed"
|
|
53
53
|
*
|
|
54
54
|
* note: this.monitoringMode = subscription_service.MonitoringMode.Reporting;
|
|
55
55
|
*/
|
|
@@ -102,8 +102,7 @@ export class ClientMonitoredItemImpl extends EventEmitter implements ClientMonit
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @async
|
|
105
|
+
* terminate the monitored item by removing the MonitoredItem from its subscription
|
|
107
106
|
*/
|
|
108
107
|
public async terminate(): Promise<void>;
|
|
109
108
|
public terminate(done: ErrorCallback): void;
|
|
@@ -25,10 +25,7 @@ const warningLog = make_warningLog(__filename);
|
|
|
25
25
|
* Finally, ClientSidePublishEngine dispatch PublishResponse to the correct
|
|
26
26
|
* Subscription id callback
|
|
27
27
|
*
|
|
28
|
-
* @
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @constructor
|
|
28
|
+
* @private
|
|
32
29
|
*/
|
|
33
30
|
export class ClientSidePublishEngine {
|
|
34
31
|
public static publishRequestCountInPipeline = 5;
|
|
@@ -98,7 +95,7 @@ export class ClientSidePublishEngine {
|
|
|
98
95
|
}
|
|
99
96
|
|
|
100
97
|
/**
|
|
101
|
-
* @
|
|
98
|
+
* @private
|
|
102
99
|
*/
|
|
103
100
|
public send_publish_request(): void {
|
|
104
101
|
if (this.isSuspended) {
|
|
@@ -127,11 +124,17 @@ export class ClientSidePublishEngine {
|
|
|
127
124
|
}
|
|
128
125
|
}
|
|
129
126
|
|
|
127
|
+
/**
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
130
|
public terminate(): void {
|
|
131
131
|
debugLog("Terminated ClientPublishEngine ");
|
|
132
132
|
this.session = null;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
135
138
|
public registerSubscription(subscription: ClientSubscription): void {
|
|
136
139
|
debugLog("ClientSidePublishEngine#registerSubscription ", subscription.subscriptionId);
|
|
137
140
|
|
|
@@ -152,6 +155,9 @@ export class ClientSidePublishEngine {
|
|
|
152
155
|
this.replenish_publish_request_queue();
|
|
153
156
|
}
|
|
154
157
|
|
|
158
|
+
/**
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
155
161
|
public replenish_publish_request_queue(): void {
|
|
156
162
|
// Spec 1.03 part 4 5.13.5 Publish
|
|
157
163
|
// [..] in high latency networks, the Client may wish to pipeline Publish requests
|
|
@@ -168,9 +174,9 @@ export class ClientSidePublishEngine {
|
|
|
168
174
|
}
|
|
169
175
|
|
|
170
176
|
/**
|
|
171
|
-
* @method unregisterSubscription
|
|
172
177
|
*
|
|
173
178
|
* @param subscriptionId
|
|
179
|
+
* @private
|
|
174
180
|
*/
|
|
175
181
|
public unregisterSubscription(subscriptionId: SubscriptionId): void {
|
|
176
182
|
debugLog("ClientSidePublishEngine#unregisterSubscription ", subscriptionId);
|
|
@@ -190,9 +190,6 @@ export interface Reconnectable {
|
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
192
|
* @class ClientSession
|
|
193
|
-
* @param client {OPCUAClientImpl}
|
|
194
|
-
* @constructor
|
|
195
|
-
* @private
|
|
196
193
|
*/
|
|
197
194
|
export class ClientSessionImpl extends EventEmitter implements ClientSession, Reconnectable {
|
|
198
195
|
static reconnectingElement: WeakMap<ClientSessionImpl, Reconnectable> = new WeakMap();
|
|
@@ -305,8 +302,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
305
302
|
});
|
|
306
303
|
}
|
|
307
304
|
/**
|
|
308
|
-
* @method browse
|
|
309
|
-
* @async
|
|
310
305
|
*
|
|
311
306
|
* @example
|
|
312
307
|
*
|
|
@@ -410,8 +405,8 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
410
405
|
if (r.references && r.references.length > this.requestedMaxReferencesPerNode) {
|
|
411
406
|
warningLog(
|
|
412
407
|
chalk.yellow("warning") +
|
|
413
|
-
|
|
414
|
-
|
|
408
|
+
" BrowseResponse : the server didn't take into" +
|
|
409
|
+
" account our requestedMaxReferencesPerNode "
|
|
415
410
|
);
|
|
416
411
|
warningLog(" this.requestedMaxReferencesPerNode= " + this.requestedMaxReferencesPerNode);
|
|
417
412
|
warningLog(" got " + r.references.length + "for " + nodesToBrowse[i].nodeId.toString());
|
|
@@ -420,7 +415,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
420
415
|
}
|
|
421
416
|
}
|
|
422
417
|
for (const r of results) {
|
|
423
|
-
r.references = r.references || /* istanbul ignore next */[];
|
|
418
|
+
r.references = r.references || /* istanbul ignore next */ [];
|
|
424
419
|
}
|
|
425
420
|
assert(results[0] instanceof BrowseResult);
|
|
426
421
|
return callback(null, isArray ? results : results[0]);
|
|
@@ -476,8 +471,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
476
471
|
}
|
|
477
472
|
|
|
478
473
|
/**
|
|
479
|
-
* @method readVariableValue
|
|
480
|
-
* @async
|
|
481
474
|
*
|
|
482
475
|
* @example
|
|
483
476
|
*
|
|
@@ -560,8 +553,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
560
553
|
}
|
|
561
554
|
|
|
562
555
|
/**
|
|
563
|
-
* @method readHistoryValue
|
|
564
|
-
* @async
|
|
565
556
|
*
|
|
566
557
|
* @example
|
|
567
558
|
*
|
|
@@ -719,7 +710,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
719
710
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
720
711
|
}
|
|
721
712
|
|
|
722
|
-
response.results = response.results || /* istanbul ignore next */[];
|
|
713
|
+
response.results = response.results || /* istanbul ignore next */ [];
|
|
723
714
|
callback(null, response);
|
|
724
715
|
});
|
|
725
716
|
}
|
|
@@ -851,7 +842,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
851
842
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
852
843
|
}
|
|
853
844
|
|
|
854
|
-
response.results = response.results || /* istanbul ignore next */[];
|
|
845
|
+
response.results = response.results || /* istanbul ignore next */ [];
|
|
855
846
|
|
|
856
847
|
assert(nodesToRead.length === response.results.length);
|
|
857
848
|
|
|
@@ -861,12 +852,11 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
861
852
|
|
|
862
853
|
/**
|
|
863
854
|
*
|
|
864
|
-
|
|
855
|
+
|
|
865
856
|
* @param nodesToWrite {WriteValue[]} - the array of value to write. One or more elements.
|
|
866
857
|
* @param {Function} callback - the callback function
|
|
867
858
|
* @param callback.err {object|null} the error if write has failed or null if OK
|
|
868
859
|
* @param callback.statusCodes {StatusCode[]} - an array of status code of each write
|
|
869
|
-
* @async
|
|
870
860
|
*
|
|
871
861
|
* @example
|
|
872
862
|
*
|
|
@@ -899,12 +889,11 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
899
889
|
* //
|
|
900
890
|
* });
|
|
901
891
|
*
|
|
902
|
-
|
|
892
|
+
|
|
903
893
|
* @param nodeToWrite {WriteValue} - the value to write
|
|
904
894
|
* @param callback - the callback function
|
|
905
895
|
* @param callback.err {object|null} the error if write has failed or null if OK
|
|
906
896
|
* @param callback.statusCode {StatusCodes} - the status code of the write
|
|
907
|
-
* @async
|
|
908
897
|
*
|
|
909
898
|
* @example
|
|
910
899
|
*
|
|
@@ -925,10 +914,9 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
925
914
|
* });
|
|
926
915
|
*
|
|
927
916
|
*
|
|
928
|
-
|
|
917
|
+
|
|
929
918
|
* @param nodeToWrite {WriteValue} - the value to write
|
|
930
919
|
* @return {Promise<StatusCode>}
|
|
931
|
-
* @async
|
|
932
920
|
*
|
|
933
921
|
* @example
|
|
934
922
|
*
|
|
@@ -942,10 +930,9 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
942
930
|
* const statusCode = await session.write(nodeToWrite);
|
|
943
931
|
* ```
|
|
944
932
|
*
|
|
945
|
-
|
|
933
|
+
|
|
946
934
|
* @param nodesToWrite {Array<WriteValue>} - the value to write
|
|
947
935
|
* @return {Promise<Array<StatusCode>>}
|
|
948
|
-
* @async
|
|
949
936
|
*
|
|
950
937
|
* @example
|
|
951
938
|
* ```javascript
|
|
@@ -994,29 +981,25 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
994
981
|
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
995
982
|
return callback(new Error(response.responseHeader.serviceResult.toString()));
|
|
996
983
|
}
|
|
997
|
-
response.results = response.results || /* istanbul ignore next */[];
|
|
984
|
+
response.results = response.results || /* istanbul ignore next */ [];
|
|
998
985
|
assert(nodesToWrite.length === response.results.length);
|
|
999
986
|
callback(null, isArray ? response.results : response.results[0]);
|
|
1000
987
|
});
|
|
1001
988
|
}
|
|
1002
989
|
|
|
1003
990
|
/**
|
|
991
|
+
* @deprecated use session.write instead
|
|
1004
992
|
*
|
|
1005
|
-
* @method writeSingleNode
|
|
1006
|
-
* @async
|
|
1007
993
|
* @param nodeId {NodeId} - the node id of the node to write
|
|
1008
994
|
* @param value {Variant} - the value to write
|
|
1009
995
|
* @param callback {Function}
|
|
1010
996
|
* @param callback.err {object|null} the error if write has failed or null if OK
|
|
1011
997
|
* @param callback.statusCode {StatusCode} - the status code of the write
|
|
1012
998
|
*
|
|
1013
|
-
* @method writeSingleNode
|
|
1014
|
-
* @async
|
|
1015
999
|
* @param nodeId {NodeId} - the node id of the node to write
|
|
1016
1000
|
* @param value {Variant} - the value to write
|
|
1017
1001
|
* @return {Promise<StatusCode>} - the status code of the write
|
|
1018
1002
|
*
|
|
1019
|
-
* @deprecated use session.write instead
|
|
1020
1003
|
*
|
|
1021
1004
|
* @example
|
|
1022
1005
|
* // please use session.write instead of session.writeSingleNode
|
|
@@ -1065,7 +1048,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1065
1048
|
}
|
|
1066
1049
|
|
|
1067
1050
|
/**
|
|
1068
|
-
|
|
1051
|
+
|
|
1069
1052
|
*
|
|
1070
1053
|
* @example
|
|
1071
1054
|
*
|
|
@@ -1081,7 +1064,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1081
1064
|
* });
|
|
1082
1065
|
* ```
|
|
1083
1066
|
*
|
|
1084
|
-
* @async
|
|
1085
1067
|
* @param nodes array of nodeId to read
|
|
1086
1068
|
* @param node nodeId to read
|
|
1087
1069
|
* @param callback
|
|
@@ -1099,9 +1081,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1099
1081
|
}
|
|
1100
1082
|
|
|
1101
1083
|
/**
|
|
1102
|
-
* @method read (form1)
|
|
1103
1084
|
*
|
|
1104
|
-
* @async
|
|
1105
1085
|
*
|
|
1106
1086
|
* @example
|
|
1107
1087
|
*
|
|
@@ -1124,13 +1104,12 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1124
1104
|
* ```
|
|
1125
1105
|
*
|
|
1126
1106
|
*
|
|
1127
|
-
|
|
1107
|
+
|
|
1128
1108
|
* @param nodesToRead {Array<ReadValueId>} - an array of nodeId to read or a ReadValueId
|
|
1129
1109
|
* @param [maxAge] {Number}
|
|
1130
1110
|
* @param callback {Function} - the callback function
|
|
1131
1111
|
* @param callback.err {Error|null} - the error or null if the transaction was OK}
|
|
1132
1112
|
* @param callback.dataValues {Array<DataValue>}
|
|
1133
|
-
* @async
|
|
1134
1113
|
*
|
|
1135
1114
|
* @example
|
|
1136
1115
|
*
|
|
@@ -1197,7 +1176,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1197
1176
|
warningLog(
|
|
1198
1177
|
chalk.yellow(
|
|
1199
1178
|
"please make sure to refactor your code and check that " +
|
|
1200
|
-
|
|
1179
|
+
"the second argument of your callback function is named"
|
|
1201
1180
|
),
|
|
1202
1181
|
chalk.cyan("dataValue" + (isArray ? "s" : ""))
|
|
1203
1182
|
);
|
|
@@ -1230,7 +1209,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1230
1209
|
|
|
1231
1210
|
// perform ExtensionObject resolution
|
|
1232
1211
|
promoteOpaqueStructureWithCallback(this, response.results!, () => {
|
|
1233
|
-
response.results = response.results || /* istanbul ignore next */[];
|
|
1212
|
+
response.results = response.results || /* istanbul ignore next */ [];
|
|
1234
1213
|
return callback(null, isArray ? response.results : response.results[0]);
|
|
1235
1214
|
});
|
|
1236
1215
|
});
|
|
@@ -1252,7 +1231,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1252
1231
|
}
|
|
1253
1232
|
|
|
1254
1233
|
/**
|
|
1255
|
-
|
|
1234
|
+
|
|
1256
1235
|
* @param createSubscriptionRequest
|
|
1257
1236
|
* @param callback
|
|
1258
1237
|
*
|
|
@@ -1301,8 +1280,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1301
1280
|
}
|
|
1302
1281
|
|
|
1303
1282
|
/**
|
|
1304
|
-
* @method transferSubscriptions
|
|
1305
|
-
* @async
|
|
1306
1283
|
*/
|
|
1307
1284
|
public transferSubscriptions(
|
|
1308
1285
|
options: TransferSubscriptionsRequestLike,
|
|
@@ -1327,12 +1304,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1327
1304
|
|
|
1328
1305
|
/**
|
|
1329
1306
|
*
|
|
1330
|
-
* @method modifySubscription
|
|
1331
|
-
* @async
|
|
1332
|
-
* @param options {ModifySubscriptionRequest}
|
|
1333
|
-
* @param callback {Function}
|
|
1334
|
-
* @param callback.err {Error|null} - the Error if the async method has failed
|
|
1335
|
-
* @param callback.response {ModifySubscriptionResponse} - the response
|
|
1336
1307
|
*/
|
|
1337
1308
|
public modifySubscription(
|
|
1338
1309
|
options: ModifySubscriptionRequestLike,
|
|
@@ -1346,13 +1317,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1346
1317
|
}
|
|
1347
1318
|
|
|
1348
1319
|
/**
|
|
1349
|
-
*
|
|
1350
|
-
* @method publish
|
|
1351
|
-
* @async
|
|
1352
|
-
* @param options {PublishRequest}
|
|
1353
|
-
* @param callback {Function}
|
|
1354
|
-
* @param callback.err {Error|null} - the Error if the async method has failed
|
|
1355
|
-
* @param callback.response {PublishResponse} - the response
|
|
1356
1320
|
*/
|
|
1357
1321
|
public publish(options: PublishRequest, callback: (err: Error | null, response?: PublishResponse) => void): void {
|
|
1358
1322
|
this._defaultRequest(PublishRequest, PublishResponse, options, callback);
|
|
@@ -1360,10 +1324,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1360
1324
|
|
|
1361
1325
|
/**
|
|
1362
1326
|
*
|
|
1363
|
-
* @method republish
|
|
1364
|
-
* @async
|
|
1365
|
-
* @param options {RepublishRequest}
|
|
1366
|
-
* @param callback the callback
|
|
1367
1327
|
*/
|
|
1368
1328
|
public republish(options: RepublishRequest, callback: (err: Error | null, response?: RepublishResponse) => void): void {
|
|
1369
1329
|
this._defaultRequest(RepublishRequest, RepublishResponse, options, callback);
|
|
@@ -1371,11 +1331,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1371
1331
|
|
|
1372
1332
|
/**
|
|
1373
1333
|
*
|
|
1374
|
-
* @method deleteMonitoredItems
|
|
1375
|
-
* @async
|
|
1376
|
-
* @param options {DeleteMonitoredItemsRequest}
|
|
1377
|
-
* @param callback {Function}
|
|
1378
|
-
* @param callback.err {Error|null} - the Error if the async method has failed
|
|
1379
1334
|
*/
|
|
1380
1335
|
public deleteMonitoredItems(
|
|
1381
1336
|
options: DeleteMonitoredItemsRequestLike,
|
|
@@ -1386,8 +1341,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1386
1341
|
|
|
1387
1342
|
/**
|
|
1388
1343
|
*
|
|
1389
|
-
* @method setPublishingMode
|
|
1390
|
-
* @async
|
|
1391
1344
|
*/
|
|
1392
1345
|
public setPublishingMode(publishingEnabled: boolean, subscriptionId: SubscriptionId): Promise<StatusCode>;
|
|
1393
1346
|
public setPublishingMode(publishingEnabled: boolean, subscriptionIds: SubscriptionId[]): Promise<StatusCode[]>;
|
|
@@ -1431,22 +1384,13 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1431
1384
|
if (!response) {
|
|
1432
1385
|
return callback(new Error("Internal Error"));
|
|
1433
1386
|
}
|
|
1434
|
-
response.results = response.results || /* istanbul ignore next */[];
|
|
1387
|
+
response.results = response.results || /* istanbul ignore next */ [];
|
|
1435
1388
|
callback(err, isArray ? response.results : response.results[0]);
|
|
1436
1389
|
}
|
|
1437
1390
|
);
|
|
1438
1391
|
}
|
|
1439
1392
|
|
|
1440
1393
|
/**
|
|
1441
|
-
*
|
|
1442
|
-
* @method translateBrowsePath
|
|
1443
|
-
* @async
|
|
1444
|
-
* @param browsePath {BrowsePath|Array<BrowsePath>}
|
|
1445
|
-
* @param callback {Function}
|
|
1446
|
-
* @param callback.err {Error|null}
|
|
1447
|
-
* @param callback.response {BrowsePathResult|Array<BrowsePathResult>}
|
|
1448
|
-
*
|
|
1449
|
-
*
|
|
1450
1394
|
*
|
|
1451
1395
|
*/
|
|
1452
1396
|
public translateBrowsePath(browsePath: BrowsePath, callback: ResponseCallback<BrowsePathResult>): void;
|
|
@@ -1476,7 +1420,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1476
1420
|
if (!response || !(response instanceof TranslateBrowsePathsToNodeIdsResponse)) {
|
|
1477
1421
|
return callback(new Error("Internal Error"));
|
|
1478
1422
|
}
|
|
1479
|
-
response.results = response.results || /* istanbul ignore next */[];
|
|
1423
|
+
response.results = response.results || /* istanbul ignore next */ [];
|
|
1480
1424
|
|
|
1481
1425
|
callback(null, isArray ? response.results : response.results[0]);
|
|
1482
1426
|
});
|
|
@@ -1501,7 +1445,11 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1501
1445
|
// session may have been closed by user ... but is still in used !!
|
|
1502
1446
|
return callback(new Error("Session has been closed and should not be used to perform a transaction anymore"));
|
|
1503
1447
|
}
|
|
1504
|
-
if (
|
|
1448
|
+
if (
|
|
1449
|
+
request instanceof PublishRequest ||
|
|
1450
|
+
request instanceof ActivateSessionRequest ||
|
|
1451
|
+
request instanceof CloseSessionRequest
|
|
1452
|
+
) {
|
|
1505
1453
|
return this._performMessageTransaction(request, callback);
|
|
1506
1454
|
}
|
|
1507
1455
|
|
|
@@ -1538,17 +1486,29 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1538
1486
|
}
|
|
1539
1487
|
this.#reprocessRequest(0, request, callback);
|
|
1540
1488
|
}
|
|
1541
|
-
#reprocessRequest = (
|
|
1542
|
-
|
|
1543
|
-
|
|
1489
|
+
#reprocessRequest = (
|
|
1490
|
+
attemptCount: number,
|
|
1491
|
+
request: Request,
|
|
1492
|
+
callback: (err: Error | null, response?: Response) => void
|
|
1493
|
+
): void => {
|
|
1494
|
+
attemptCount > 0 &&
|
|
1495
|
+
warningLog("reprocessRequest => ", request.constructor.name, this._reconnecting.pendingTransactions.length);
|
|
1544
1496
|
this._performMessageTransaction(request, (err: null | Error, response?: Response) => {
|
|
1545
1497
|
if (err && err.message.match(/BadSessionIdInvalid/) && request.constructor.name !== "ActivateSessionRequest") {
|
|
1546
|
-
warningLog(
|
|
1498
|
+
warningLog(
|
|
1499
|
+
"Transaction on Invalid Session ",
|
|
1500
|
+
request.constructor.name,
|
|
1501
|
+
err.message,
|
|
1502
|
+
"isReconnecting?=",
|
|
1503
|
+
this.isReconnecting,
|
|
1504
|
+
"q=",
|
|
1505
|
+
this._reconnecting.pendingTransactions.length
|
|
1506
|
+
);
|
|
1547
1507
|
request.requestHeader.requestHandle = requestHandleNotSetValue;
|
|
1548
1508
|
if (this.isReconnecting) {
|
|
1549
1509
|
this.once("session_restored", () => {
|
|
1550
1510
|
warningLog("redoing", request.constructor.name, this.isReconnecting);
|
|
1551
|
-
this.#reprocessRequest(attemptCount+1,request, callback);
|
|
1511
|
+
this.#reprocessRequest(attemptCount + 1, request, callback);
|
|
1552
1512
|
});
|
|
1553
1513
|
} else {
|
|
1554
1514
|
this.#_recreate_session_and_reperform_transaction(request, callback);
|
|
@@ -1613,9 +1573,9 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1613
1573
|
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
|
|
1614
1574
|
err = new Error(
|
|
1615
1575
|
" ServiceResult is " +
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1576
|
+
response.responseHeader.serviceResult.toString() +
|
|
1577
|
+
" request was " +
|
|
1578
|
+
request.constructor.name
|
|
1619
1579
|
);
|
|
1620
1580
|
|
|
1621
1581
|
if (response && response.responseHeader.serviceDiagnostics) {
|
|
@@ -1669,10 +1629,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1669
1629
|
|
|
1670
1630
|
/**
|
|
1671
1631
|
*
|
|
1672
|
-
* @method close
|
|
1673
|
-
* @async
|
|
1674
|
-
* @param [deleteSubscription=true] {Boolean}
|
|
1675
|
-
* @param callback {Function}
|
|
1676
1632
|
*/
|
|
1677
1633
|
public close(callback: ErrorCallback): void;
|
|
1678
1634
|
|
|
@@ -1710,7 +1666,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1710
1666
|
}
|
|
1711
1667
|
|
|
1712
1668
|
/**
|
|
1713
|
-
|
|
1669
|
+
|
|
1714
1670
|
* @return {Boolean}
|
|
1715
1671
|
*/
|
|
1716
1672
|
public hasBeenClosed(): boolean {
|
|
@@ -1759,7 +1715,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1759
1715
|
}
|
|
1760
1716
|
|
|
1761
1717
|
/**
|
|
1762
|
-
|
|
1718
|
+
|
|
1763
1719
|
* @param subscriptionId {UInt32} the subscription Id to return
|
|
1764
1720
|
* @param callback {Function}
|
|
1765
1721
|
* @param callback.err {Error}
|
|
@@ -1821,10 +1777,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1821
1777
|
}
|
|
1822
1778
|
|
|
1823
1779
|
/**
|
|
1824
|
-
* @method getArgumentDefinition
|
|
1825
|
-
* extract the argument definition of a method
|
|
1826
|
-
* @param methodId the method nodeId to get argument definition from
|
|
1827
|
-
* @async
|
|
1828
1780
|
*
|
|
1829
1781
|
*/
|
|
1830
1782
|
public async getArgumentDefinition(methodId: MethodId): Promise<ArgumentDefinition>;
|
|
@@ -1868,7 +1820,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
1868
1820
|
return callback(new Error("Internal Error"));
|
|
1869
1821
|
}
|
|
1870
1822
|
|
|
1871
|
-
response.registeredNodeIds = response.registeredNodeIds || /* istanbul ignore next */[];
|
|
1823
|
+
response.registeredNodeIds = response.registeredNodeIds || /* istanbul ignore next */ [];
|
|
1872
1824
|
|
|
1873
1825
|
callback(null, response.registeredNodeIds);
|
|
1874
1826
|
});
|
|
@@ -2092,10 +2044,9 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
2092
2044
|
return getExtensionObjectConstructor(this, dataTypeNodeId);
|
|
2093
2045
|
}
|
|
2094
2046
|
/**
|
|
2095
|
-
*
|
|
2047
|
+
* construct a Extension object from a DataType and a pojo
|
|
2096
2048
|
* @param dataType
|
|
2097
2049
|
* @param pojo
|
|
2098
|
-
* @async
|
|
2099
2050
|
*/
|
|
2100
2051
|
public async constructExtensionObject(dataType: NodeId, pojo: Record<string, any>): Promise<ExtensionObject> {
|
|
2101
2052
|
const Constructor = await this.getExtensionObjectConstructor(dataType);
|
|
@@ -2173,10 +2124,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
2173
2124
|
callback(null, response);
|
|
2174
2125
|
});
|
|
2175
2126
|
}
|
|
2176
|
-
#_recreate_session_and_reperform_transaction(
|
|
2177
|
-
request: Request,
|
|
2178
|
-
callback: (err: Error | null, response?: Response) => void
|
|
2179
|
-
) {
|
|
2127
|
+
#_recreate_session_and_reperform_transaction(request: Request, callback: (err: Error | null, response?: Response) => void) {
|
|
2180
2128
|
warningLog("attempt to recreate session to reperform a transaction ", request.constructor.name);
|
|
2181
2129
|
if (this.recursive_repair_detector >= 1) {
|
|
2182
2130
|
// tslint:disable-next-line: no-console
|
|
@@ -2195,7 +2143,6 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
|
|
|
2195
2143
|
this._performMessageTransaction(request, callback);
|
|
2196
2144
|
});
|
|
2197
2145
|
}
|
|
2198
|
-
|
|
2199
2146
|
}
|
|
2200
2147
|
|
|
2201
2148
|
type promoteOpaqueStructure3WithCallbackFunc = (
|