node-opcua-transport 2.51.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/.mocharc.yml +10 -0
- package/LICENSE +20 -0
- package/dist/source/AcknowledgeMessage.d.ts +27 -0
- package/dist/source/AcknowledgeMessage.js +79 -0
- package/dist/source/AcknowledgeMessage.js.map +1 -0
- package/dist/source/HelloMessage.d.ts +27 -0
- package/dist/source/HelloMessage.js +95 -0
- package/dist/source/HelloMessage.js.map +1 -0
- package/dist/source/TCPErrorMessage.d.ts +18 -0
- package/dist/source/TCPErrorMessage.js +47 -0
- package/dist/source/TCPErrorMessage.js.map +1 -0
- package/dist/source/client_tcp_transport.d.ts +68 -0
- package/dist/source/client_tcp_transport.js +315 -0
- package/dist/source/client_tcp_transport.js.map +1 -0
- package/dist/source/index.d.ts +11 -0
- package/dist/source/index.js +24 -0
- package/dist/source/index.js.map +1 -0
- package/dist/source/message_builder_base.d.ts +61 -0
- package/dist/source/message_builder_base.js +207 -0
- package/dist/source/message_builder_base.js.map +1 -0
- package/dist/source/server_tcp_transport.d.ts +45 -0
- package/dist/source/server_tcp_transport.js +232 -0
- package/dist/source/server_tcp_transport.js.map +1 -0
- package/dist/source/tcp_transport.d.ts +117 -0
- package/dist/source/tcp_transport.js +350 -0
- package/dist/source/tcp_transport.js.map +1 -0
- package/dist/source/tools.d.ts +13 -0
- package/dist/source/tools.js +99 -0
- package/dist/source/tools.js.map +1 -0
- package/dist/source/utils.d.ts +2 -0
- package/dist/source/utils.js +9 -0
- package/dist/source/utils.js.map +1 -0
- package/dist/test-fixtures/fixture_full_tcp_packets.d.ts +21 -0
- package/dist/test-fixtures/fixture_full_tcp_packets.js +413 -0
- package/dist/test-fixtures/fixture_full_tcp_packets.js.map +1 -0
- package/dist/test-fixtures/index.d.ts +1 -0
- package/dist/test-fixtures/index.js +14 -0
- package/dist/test-fixtures/index.js.map +1 -0
- package/dist/test_helpers/direct_transport.d.ts +14 -0
- package/dist/test_helpers/direct_transport.js +63 -0
- package/dist/test_helpers/direct_transport.js.map +1 -0
- package/dist/test_helpers/fake_server.d.ts +15 -0
- package/dist/test_helpers/fake_server.js +56 -0
- package/dist/test_helpers/fake_server.js.map +1 -0
- package/dist/test_helpers/half_com_channel.d.ts +10 -0
- package/dist/test_helpers/half_com_channel.js +35 -0
- package/dist/test_helpers/half_com_channel.js.map +1 -0
- package/dist/test_helpers/index.d.ts +4 -0
- package/dist/test_helpers/index.js +17 -0
- package/dist/test_helpers/index.js.map +1 -0
- package/dist/test_helpers/socket_transport.d.ts +8 -0
- package/dist/test_helpers/socket_transport.js +30 -0
- package/dist/test_helpers/socket_transport.js.map +1 -0
- package/package.json +50 -0
- package/source/AcknowledgeMessage.ts +112 -0
- package/source/HelloMessage.ts +133 -0
- package/source/TCPErrorMessage.ts +57 -0
- package/source/client_tcp_transport.ts +366 -0
- package/source/index.ts +11 -0
- package/source/message_builder_base.ts +263 -0
- package/source/server_tcp_transport.ts +284 -0
- package/source/tcp_transport.ts +450 -0
- package/source/tools.ts +113 -0
- package/source/utils.ts +4 -0
- package/test_helpers/direct_transport.ts +78 -0
- package/test_helpers/fake_server.ts +71 -0
- package/test_helpers/half_com_channel.ts +38 -0
- package/test_helpers/index.ts +4 -0
- package/test_helpers/socket_transport.ts +34 -0
package/.mocharc.yml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2021 Etienne Rossignon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-transport
|
|
3
|
+
*/
|
|
4
|
+
import { UInt32 } from "node-opcua-basic-types";
|
|
5
|
+
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
6
|
+
import { BaseUAObject, StructuredTypeSchema } from "node-opcua-factory";
|
|
7
|
+
interface AcknowledgeMessageOptions {
|
|
8
|
+
protocolVersion?: UInt32;
|
|
9
|
+
receiveBufferSize?: UInt32;
|
|
10
|
+
sendBufferSize?: UInt32;
|
|
11
|
+
maxMessageSize?: UInt32;
|
|
12
|
+
maxChunkCount?: UInt32;
|
|
13
|
+
}
|
|
14
|
+
export declare class AcknowledgeMessage extends BaseUAObject {
|
|
15
|
+
static possibleFields: string[];
|
|
16
|
+
static schema: StructuredTypeSchema;
|
|
17
|
+
protocolVersion: UInt32;
|
|
18
|
+
receiveBufferSize: UInt32;
|
|
19
|
+
sendBufferSize: UInt32;
|
|
20
|
+
maxMessageSize: UInt32;
|
|
21
|
+
maxChunkCount: UInt32;
|
|
22
|
+
constructor(options?: AcknowledgeMessageOptions);
|
|
23
|
+
encode(stream: OutputBinaryStream): void;
|
|
24
|
+
decode(stream: BinaryStream): void;
|
|
25
|
+
toString(): string;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AcknowledgeMessage = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-transport
|
|
6
|
+
*/
|
|
7
|
+
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
8
|
+
const node_opcua_factory_1 = require("node-opcua-factory");
|
|
9
|
+
const schemaAcknowledgeMessage = (0, node_opcua_factory_1.buildStructuredType)({
|
|
10
|
+
name: "AcknowledgeMessage",
|
|
11
|
+
baseType: "BaseObjectType",
|
|
12
|
+
fields: [
|
|
13
|
+
{
|
|
14
|
+
name: "protocolVersion",
|
|
15
|
+
fieldType: "UInt32",
|
|
16
|
+
documentation: "The latest version of the OPC UA TCP protocol supported by the Server."
|
|
17
|
+
},
|
|
18
|
+
{ name: "receiveBufferSize", fieldType: "UInt32" },
|
|
19
|
+
{ name: "sendBufferSize", fieldType: "UInt32" },
|
|
20
|
+
{ name: "maxMessageSize", fieldType: "UInt32", documentation: "The maximum size for any request message." },
|
|
21
|
+
{
|
|
22
|
+
name: "maxChunkCount",
|
|
23
|
+
fieldType: "UInt32",
|
|
24
|
+
documentation: "The maximum number of chunks in any request message."
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
class AcknowledgeMessage extends node_opcua_factory_1.BaseUAObject {
|
|
29
|
+
constructor(options) {
|
|
30
|
+
options = options || {};
|
|
31
|
+
super();
|
|
32
|
+
const schema = schemaAcknowledgeMessage;
|
|
33
|
+
/* istanbul ignore next */
|
|
34
|
+
if (node_opcua_factory_1.parameters.debugSchemaHelper) {
|
|
35
|
+
(0, node_opcua_factory_1.check_options_correctness_against_schema)(this, schema, options);
|
|
36
|
+
}
|
|
37
|
+
this.protocolVersion = (0, node_opcua_factory_1.initialize_field)(schema.fields[0], options.protocolVersion);
|
|
38
|
+
this.receiveBufferSize = (0, node_opcua_factory_1.initialize_field)(schema.fields[1], options.receiveBufferSize);
|
|
39
|
+
this.sendBufferSize = (0, node_opcua_factory_1.initialize_field)(schema.fields[2], options.sendBufferSize);
|
|
40
|
+
this.maxMessageSize = (0, node_opcua_factory_1.initialize_field)(schema.fields[3], options.maxMessageSize);
|
|
41
|
+
this.maxChunkCount = (0, node_opcua_factory_1.initialize_field)(schema.fields[4], options.maxChunkCount);
|
|
42
|
+
}
|
|
43
|
+
encode(stream) {
|
|
44
|
+
super.encode(stream);
|
|
45
|
+
(0, node_opcua_basic_types_1.encodeUInt32)(this.protocolVersion, stream);
|
|
46
|
+
(0, node_opcua_basic_types_1.encodeUInt32)(this.receiveBufferSize, stream);
|
|
47
|
+
(0, node_opcua_basic_types_1.encodeUInt32)(this.sendBufferSize, stream);
|
|
48
|
+
(0, node_opcua_basic_types_1.encodeUInt32)(this.maxMessageSize, stream);
|
|
49
|
+
(0, node_opcua_basic_types_1.encodeUInt32)(this.maxChunkCount, stream);
|
|
50
|
+
}
|
|
51
|
+
decode(stream) {
|
|
52
|
+
// call base class implementation first
|
|
53
|
+
super.decode(stream);
|
|
54
|
+
this.protocolVersion = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
|
|
55
|
+
this.receiveBufferSize = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
|
|
56
|
+
this.sendBufferSize = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
|
|
57
|
+
this.maxMessageSize = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
|
|
58
|
+
this.maxChunkCount = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
|
|
59
|
+
}
|
|
60
|
+
toString() {
|
|
61
|
+
let str = "";
|
|
62
|
+
str += 'protocolVersion = ' + this.protocolVersion + '\n';
|
|
63
|
+
str += 'receiveBufferSize = ' + this.receiveBufferSize + '\n';
|
|
64
|
+
str += 'sendBufferSize = ' + this.sendBufferSize + '\n';
|
|
65
|
+
str += 'maxMessageSize = ' + this.maxMessageSize + '\n';
|
|
66
|
+
str += 'maxChunkCount = ' + this.maxChunkCount + '\n';
|
|
67
|
+
return str;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.AcknowledgeMessage = AcknowledgeMessage;
|
|
71
|
+
AcknowledgeMessage.possibleFields = [
|
|
72
|
+
"protocolVersion",
|
|
73
|
+
"receiveBufferSize",
|
|
74
|
+
"sendBufferSize",
|
|
75
|
+
"maxMessageSize",
|
|
76
|
+
"maxChunkCount"
|
|
77
|
+
];
|
|
78
|
+
AcknowledgeMessage.schema = schemaAcknowledgeMessage;
|
|
79
|
+
//# sourceMappingURL=AcknowledgeMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcknowledgeMessage.js","sourceRoot":"","sources":["../../source/AcknowledgeMessage.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mEAA4E;AAE5E,2DAM4B;AAE5B,MAAM,wBAAwB,GAAyB,IAAA,wCAAmB,EAAC;IACvE,IAAI,EAAE,oBAAoB;IAE1B,QAAQ,EAAE,gBAAgB;IAE1B,MAAM,EAAE;QACJ;YACI,IAAI,EAAE,iBAAiB;YAEvB,SAAS,EAAE,QAAQ;YAEnB,aAAa,EAAE,wEAAwE;SAC1F;QACD,EAAE,IAAI,EAAE,mBAAmB,EAAE,SAAS,EAAE,QAAQ,EAAE;QAClD,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE;QAC/C,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,2CAA2C,EAAE;QAC3G;YACI,IAAI,EAAE,eAAe;YAErB,SAAS,EAAE,QAAQ;YAEnB,aAAa,EAAE,sDAAsD;SACxE;KACJ;CACJ,CAAC,CAAC;AAUH,MAAa,kBAAmB,SAAQ,iCAAY;IAiB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cua-basic-types";
|
|
5
|
+
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
6
|
+
import { BaseUAObject } from "node-opcua-factory";
|
|
7
|
+
export interface HelloMessageOptions {
|
|
8
|
+
protocolVersion?: UInt32;
|
|
9
|
+
receiveBufferSize?: UInt32;
|
|
10
|
+
sendBufferSize?: UInt32;
|
|
11
|
+
maxMessageSize?: UInt32;
|
|
12
|
+
maxChunkCount?: UInt32;
|
|
13
|
+
endpointUrl?: UAString;
|
|
14
|
+
}
|
|
15
|
+
export declare class HelloMessage extends BaseUAObject {
|
|
16
|
+
static possibleFields: string[];
|
|
17
|
+
protocolVersion: UInt32;
|
|
18
|
+
receiveBufferSize: UInt32;
|
|
19
|
+
sendBufferSize: UInt32;
|
|
20
|
+
maxMessageSize: UInt32;
|
|
21
|
+
maxChunkCount: UInt32;
|
|
22
|
+
endpointUrl: UAString;
|
|
23
|
+
constructor(options?: HelloMessageOptions);
|
|
24
|
+
encode(stream: OutputBinaryStream): void;
|
|
25
|
+
decode(stream: BinaryStream): void;
|
|
26
|
+
toString(): string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HelloMessage = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-transport
|
|
6
|
+
*/
|
|
7
|
+
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
8
|
+
const node_opcua_factory_1 = require("node-opcua-factory");
|
|
9
|
+
const schemaHelloMessage = (0, node_opcua_factory_1.buildStructuredType)({
|
|
10
|
+
name: "HelloMessage",
|
|
11
|
+
baseType: "BaseUAObject",
|
|
12
|
+
fields: [
|
|
13
|
+
{
|
|
14
|
+
name: "protocolVersion",
|
|
15
|
+
fieldType: "UInt32",
|
|
16
|
+
documentation: "The latest version of the OPC UA TCP protocol supported by the Client"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "receiveBufferSize",
|
|
20
|
+
fieldType: "UInt32",
|
|
21
|
+
documentation: "The largest message that the sender can receive."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "sendBufferSize",
|
|
25
|
+
fieldType: "UInt32",
|
|
26
|
+
documentation: "The largest message that the sender will send."
|
|
27
|
+
},
|
|
28
|
+
{ name: "maxMessageSize", fieldType: "UInt32", documentation: "The maximum size for any response message." },
|
|
29
|
+
{
|
|
30
|
+
name: "maxChunkCount",
|
|
31
|
+
fieldType: "UInt32",
|
|
32
|
+
documentation: "The maximum number of chunks in any response message"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "endpointUrl",
|
|
36
|
+
fieldType: "UAString",
|
|
37
|
+
documentation: "The URL of the Endpoint which the Client wished to connect to."
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
class HelloMessage extends node_opcua_factory_1.BaseUAObject {
|
|
42
|
+
constructor(options) {
|
|
43
|
+
options = options || {};
|
|
44
|
+
super();
|
|
45
|
+
const schema = schemaHelloMessage;
|
|
46
|
+
/* istanbul ignore next */
|
|
47
|
+
if (node_opcua_factory_1.parameters.debugSchemaHelper) {
|
|
48
|
+
(0, node_opcua_factory_1.check_options_correctness_against_schema)(this, schema, options);
|
|
49
|
+
}
|
|
50
|
+
this.protocolVersion = (0, node_opcua_factory_1.initialize_field)(schema.fields[0], options.protocolVersion);
|
|
51
|
+
this.receiveBufferSize = (0, node_opcua_factory_1.initialize_field)(schema.fields[1], options.receiveBufferSize);
|
|
52
|
+
this.sendBufferSize = (0, node_opcua_factory_1.initialize_field)(schema.fields[2], options.sendBufferSize);
|
|
53
|
+
this.maxMessageSize = (0, node_opcua_factory_1.initialize_field)(schema.fields[3], options.maxMessageSize);
|
|
54
|
+
this.maxChunkCount = (0, node_opcua_factory_1.initialize_field)(schema.fields[4], options.maxChunkCount);
|
|
55
|
+
this.endpointUrl = (0, node_opcua_factory_1.initialize_field)(schema.fields[5], options.endpointUrl);
|
|
56
|
+
}
|
|
57
|
+
encode(stream) {
|
|
58
|
+
super.encode(stream);
|
|
59
|
+
(0, node_opcua_basic_types_1.encodeUInt32)(this.protocolVersion, stream);
|
|
60
|
+
(0, node_opcua_basic_types_1.encodeUInt32)(this.receiveBufferSize, stream);
|
|
61
|
+
(0, node_opcua_basic_types_1.encodeUInt32)(this.sendBufferSize, stream);
|
|
62
|
+
(0, node_opcua_basic_types_1.encodeUInt32)(this.maxMessageSize, stream);
|
|
63
|
+
(0, node_opcua_basic_types_1.encodeUInt32)(this.maxChunkCount, stream);
|
|
64
|
+
(0, node_opcua_basic_types_1.encodeUAString)(this.endpointUrl, stream);
|
|
65
|
+
}
|
|
66
|
+
decode(stream) {
|
|
67
|
+
super.decode(stream);
|
|
68
|
+
this.protocolVersion = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
|
|
69
|
+
this.receiveBufferSize = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
|
|
70
|
+
this.sendBufferSize = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
|
|
71
|
+
this.maxMessageSize = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
|
|
72
|
+
this.maxChunkCount = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
|
|
73
|
+
this.endpointUrl = (0, node_opcua_basic_types_1.decodeUAString)(stream);
|
|
74
|
+
}
|
|
75
|
+
toString() {
|
|
76
|
+
let str = "";
|
|
77
|
+
str += 'protocolVersion = ' + this.protocolVersion + '\n';
|
|
78
|
+
str += 'receiveBufferSize = ' + this.receiveBufferSize + '\n';
|
|
79
|
+
str += 'sendBufferSize = ' + this.sendBufferSize + '\n';
|
|
80
|
+
str += 'maxMessageSize = ' + this.maxMessageSize + '\n';
|
|
81
|
+
str += 'maxChunkCount = ' + this.maxChunkCount + '\n';
|
|
82
|
+
str += 'endpointUrl = ' + this.endpointUrl + '\n';
|
|
83
|
+
return str;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.HelloMessage = HelloMessage;
|
|
87
|
+
HelloMessage.possibleFields = [
|
|
88
|
+
"protocolVersion",
|
|
89
|
+
"receiveBufferSize",
|
|
90
|
+
"sendBufferSize",
|
|
91
|
+
"maxMessageSize",
|
|
92
|
+
"maxChunkCount",
|
|
93
|
+
"endpointUrl"
|
|
94
|
+
];
|
|
95
|
+
//# sourceMappingURL=HelloMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HelloMessage.js","sourceRoot":"","sources":["../../source/HelloMessage.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mEAGgC;AAEhC,2DAK4B;AAE5B,MAAM,kBAAkB,GAAyB,IAAA,wCAAmB,EAAC;IACjE,IAAI,EAAE,cAAc;IAEpB,QAAQ,EAAE,cAAc;IAExB,MAAM,EAAE;QACJ;YACI,IAAI,EAAE,iBAAiB;YAEvB,SAAS,EAAE,QAAQ;YAEnB,aAAa,EAAE,uEAAuE;SACzF;QACD;YACI,IAAI,EAAE,mBAAmB;YAEzB,SAAS,EAAE,QAAQ;YAEnB,aAAa,EAAE,kDAAkD;SACpE;QACD;YACI,IAAI,EAAE,gBAAgB;YAEtB,SAAS,EAAE,QAAQ;YAEnB,aAAa,EAAE,gDAAgD;SAClE;QACD,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,4CAA4C,EAAE;QAC5G;YACI,IAAI,EAAE,eAAe;YAErB,SAAS,EAAE,QAAQ;YAEnB,aAAa,EAAE,sDAAsD;SACxE;QACD;YACI,IAAI,EAAE,aAAa;YAEnB,SAAS,EAAE,UAAU;YAErB,aAAa,EAAE,gEAAgE;SAClF;KACJ;CACJ,CAAC,CAAC;AAWH,MAAa,YAAa,SAAQ,iCAAY;IAiB1C,YAAY,OAA6B;QACrC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,KAAK,EAAE,CAAC;QACR,MAAM,MAAM,GAAG,kBAAkB,CA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AgB;IAChB,gBAAgB;IAChB,eAAe;IACf,aAAa;CAChB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-transport
|
|
3
|
+
*/
|
|
4
|
+
import { UAString } from "node-opcua-basic-types";
|
|
5
|
+
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
6
|
+
import { BaseUAObject } from "node-opcua-factory";
|
|
7
|
+
import { StatusCode } from "node-opcua-status-code";
|
|
8
|
+
export declare class TCPErrorMessage extends BaseUAObject {
|
|
9
|
+
static possibleFields: string[];
|
|
10
|
+
statusCode: StatusCode;
|
|
11
|
+
reason: UAString;
|
|
12
|
+
constructor(options?: {
|
|
13
|
+
statusCode?: StatusCode;
|
|
14
|
+
reason?: string;
|
|
15
|
+
});
|
|
16
|
+
encode(stream: OutputBinaryStream): void;
|
|
17
|
+
decode(stream: BinaryStream): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TCPErrorMessage = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-transport
|
|
6
|
+
*/
|
|
7
|
+
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
8
|
+
const node_opcua_factory_1 = require("node-opcua-factory");
|
|
9
|
+
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
10
|
+
// TCP Error Message OPC Unified Architecture, Part 6 page 46
|
|
11
|
+
// the server always close the connection after sending the TCPError message
|
|
12
|
+
const schemaTCPErrorMessage = (0, node_opcua_factory_1.buildStructuredType)({
|
|
13
|
+
name: "TCPErrorMessage",
|
|
14
|
+
baseType: "BaseUAObject",
|
|
15
|
+
fields: [
|
|
16
|
+
{ name: "statusCode", fieldType: "StatusCode" },
|
|
17
|
+
{ name: "reason", fieldType: "String" } // A more verbose description of the error.
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
class TCPErrorMessage extends node_opcua_factory_1.BaseUAObject {
|
|
21
|
+
constructor(options) {
|
|
22
|
+
options = options || {};
|
|
23
|
+
const schema = schemaTCPErrorMessage;
|
|
24
|
+
super();
|
|
25
|
+
/* istanbul ignore next */
|
|
26
|
+
if (node_opcua_factory_1.parameters.debugSchemaHelper) {
|
|
27
|
+
(0, node_opcua_factory_1.check_options_correctness_against_schema)(this, schema, options);
|
|
28
|
+
}
|
|
29
|
+
this.statusCode = (0, node_opcua_factory_1.initialize_field)(schema.fields[0], options.statusCode);
|
|
30
|
+
this.reason = (0, node_opcua_factory_1.initialize_field)(schema.fields[1], options.reason);
|
|
31
|
+
}
|
|
32
|
+
encode(stream) {
|
|
33
|
+
// call base class implementation first
|
|
34
|
+
super.encode(stream);
|
|
35
|
+
(0, node_opcua_status_code_1.encodeStatusCode)(this.statusCode, stream);
|
|
36
|
+
(0, node_opcua_basic_types_1.encodeString)(this.reason, stream);
|
|
37
|
+
}
|
|
38
|
+
decode(stream) {
|
|
39
|
+
// call base class implementation first
|
|
40
|
+
super.decode(stream);
|
|
41
|
+
this.statusCode = (0, node_opcua_status_code_1.decodeStatusCode)(stream);
|
|
42
|
+
this.reason = (0, node_opcua_basic_types_1.decodeString)(stream);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.TCPErrorMessage = TCPErrorMessage;
|
|
46
|
+
TCPErrorMessage.possibleFields = ["statusCode", "reason"];
|
|
47
|
+
//# sourceMappingURL=TCPErrorMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TCPErrorMessage.js","sourceRoot":"","sources":["../../source/TCPErrorMessage.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mEAA8E;AAE9E,2DAK4B;AAC5B,mEAAwF;AAExF,8DAA8D;AAC9D,4EAA4E;AAC5E,MAAM,qBAAqB,GAAG,IAAA,wCAAmB,EAAC;IAC9C,IAAI,EAAE,iBAAiB;IAEvB,QAAQ,E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7BiB,8BAAc,GAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ErrorCallback } from "node-opcua-status-code";
|
|
3
|
+
import { TCP_transport } from "./tcp_transport";
|
|
4
|
+
import { AcknowledgeMessage } from "./AcknowledgeMessage";
|
|
5
|
+
export interface ClientTCP_transport {
|
|
6
|
+
on(eventName: "message", eventHandler: (message: Buffer) => void): this;
|
|
7
|
+
once(eventName: "message", eventHandler: (message: Buffer) => void): this;
|
|
8
|
+
on(eventName: "socket_closed", eventHandler: (err: Error | null) => void): this;
|
|
9
|
+
once(eventName: "socket_closed", eventHandler: (err: Error | null) => void): this;
|
|
10
|
+
on(eventName: "close", eventHandler: (err: Error | null) => void): this;
|
|
11
|
+
once(eventName: "close", eventHandler: (err: Error | null) => void): this;
|
|
12
|
+
on(eventName: "connection_break", eventHandler: () => void): this;
|
|
13
|
+
once(eventName: "connection_break", eventHandler: () => void): this;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* a ClientTCP_transport connects to a remote server socket and
|
|
17
|
+
* initiates a communication with a HEL/ACK transaction.
|
|
18
|
+
* It negotiates the communication parameters with the other end.
|
|
19
|
+
*
|
|
20
|
+
* @class ClientTCP_transport
|
|
21
|
+
* @extends TCP_transport
|
|
22
|
+
* @constructor
|
|
23
|
+
* @example
|
|
24
|
+
*
|
|
25
|
+
* ```javascript
|
|
26
|
+
* const transport = ClientTCP_transport(url);
|
|
27
|
+
*
|
|
28
|
+
* transport.timeout = 10000;
|
|
29
|
+
*
|
|
30
|
+
* transport.connect(function(err)) {
|
|
31
|
+
* if (err) {
|
|
32
|
+
* // cannot connect
|
|
33
|
+
* } else {
|
|
34
|
+
* // connected
|
|
35
|
+
*
|
|
36
|
+
* }
|
|
37
|
+
* });
|
|
38
|
+
* ....
|
|
39
|
+
*
|
|
40
|
+
* transport.write(message_chunk,'F');
|
|
41
|
+
*
|
|
42
|
+
* ....
|
|
43
|
+
*
|
|
44
|
+
* transport.on("message",function(message_chunk) {
|
|
45
|
+
* // do something with message from server...
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
*
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
export declare class ClientTCP_transport extends TCP_transport {
|
|
54
|
+
endpointUrl: string;
|
|
55
|
+
serverUri: string;
|
|
56
|
+
numberOfRetry: number;
|
|
57
|
+
parameters?: AcknowledgeMessage;
|
|
58
|
+
private connected;
|
|
59
|
+
private _counter;
|
|
60
|
+
constructor();
|
|
61
|
+
dispose(): void;
|
|
62
|
+
connect(endpointUrl: string, callback: ErrorCallback): void;
|
|
63
|
+
protected on_socket_ended(err: Error | null): void;
|
|
64
|
+
private _handle_ACK_response;
|
|
65
|
+
private _send_HELLO_request;
|
|
66
|
+
private _on_ACK_response;
|
|
67
|
+
private _perform_HEL_ACK_transaction;
|
|
68
|
+
}
|