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
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FakeServer = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const net = require("net");
|
|
6
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
7
|
+
const port = 5678;
|
|
8
|
+
class FakeServer extends events_1.EventEmitter {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.port = port;
|
|
12
|
+
this.url = "opc.tcp://localhost:" + port;
|
|
13
|
+
this.tcpServer = new net.Server();
|
|
14
|
+
this._serverSocket = undefined;
|
|
15
|
+
this.tcpServer.on("connection", (socket) => {
|
|
16
|
+
(0, node_opcua_assert_1.assert)(!this._serverSocket, " already connected");
|
|
17
|
+
this._serverSocket = socket;
|
|
18
|
+
this._serverSocket.on("data", (data) => {
|
|
19
|
+
const func = this.popResponse();
|
|
20
|
+
if (func) {
|
|
21
|
+
func(this._serverSocket, data);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
this._serverSocket.on("err", (err) => {
|
|
25
|
+
// console.log(" @@@@ socket err ",err);
|
|
26
|
+
});
|
|
27
|
+
this._serverSocket.on("close", (err) => {
|
|
28
|
+
// console.log(" @@@@ socket closed ",err);
|
|
29
|
+
});
|
|
30
|
+
this._serverSocket.on("end", (err) => {
|
|
31
|
+
// console.log(" @@@@ socket end ",err);
|
|
32
|
+
this.emit("end", err);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
initialize(done) {
|
|
37
|
+
this.tcpServer.listen(this.port, () => {
|
|
38
|
+
done();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
shutdown(callback) {
|
|
42
|
+
this.tcpServer.close(callback);
|
|
43
|
+
}
|
|
44
|
+
popResponse() {
|
|
45
|
+
if (!this._responses) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return this._responses.shift();
|
|
49
|
+
}
|
|
50
|
+
pushResponse(func) {
|
|
51
|
+
this._responses = this._responses || [];
|
|
52
|
+
this._responses.push(func);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.FakeServer = FakeServer;
|
|
56
|
+
//# sourceMappingURL=fake_server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake_server.js","sourceRoot":"","sources":["../../test_helpers/fake_server.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AACtC,2BAA4B;AAC5B,yDAA2C;AAE3C,MAAM,IAAI,GAAG,IAAI,CAAC;AAElB,MAAa,UAAW,SAAQ,qBAAY;IAQxC;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,GAAG,GAAG,sBAAsB,GAAG,IAAI,CAAC;QAEzC,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QAElC,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QAE/B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,MAAkB,EAAE,EAAE;YACnD,IAAA,0BAAM,EAAC,CAAC,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;YAClD,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;YAE5B,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;gBAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;gBAChC,IAAI,IAAI,EAAE;oBACN,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;iBAClC;YACL,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAU,EAAE,EAAE;gBACxC,wCAAwC;YAC5C,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE;gBAC3C,2CAA2C;YAC/C,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE;gBACzC,wCAAwC;gBACxC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,UAAU,CAAC,IAAgB;QAE9B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE;YAClC,IAAI,EAAE,CAAC;QACX,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,QAAQ,CAAC,QAA+B;QAC3C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAEM,WAAW;QACd,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,OAAO,IAAI,CAAC;SACf;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACnC,CAAC;IAEM,YAAY,CAAC,IAAS;QACzB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;QACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CAEJ;AAhED,gCAgEC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
export declare class HalfComChannel extends EventEmitter {
|
|
4
|
+
_hasEnded: boolean;
|
|
5
|
+
constructor();
|
|
6
|
+
write(data: string | Buffer): void;
|
|
7
|
+
end(): void;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
setTimeout(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HalfComChannel = void 0;
|
|
4
|
+
// tslint:disable:no-empty
|
|
5
|
+
// tslint:disable:unused-variable
|
|
6
|
+
const events_1 = require("events");
|
|
7
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
8
|
+
class HalfComChannel extends events_1.EventEmitter {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this._hasEnded = false;
|
|
12
|
+
}
|
|
13
|
+
write(data) {
|
|
14
|
+
if (typeof data === "string") {
|
|
15
|
+
data = Buffer.from(data);
|
|
16
|
+
}
|
|
17
|
+
(0, node_opcua_assert_1.assert)(data instanceof Buffer, "HalfComChannel.write expecting a buffer");
|
|
18
|
+
const copy = Buffer.concat([data]);
|
|
19
|
+
this.emit("send_data", copy);
|
|
20
|
+
}
|
|
21
|
+
end() {
|
|
22
|
+
if (!this._hasEnded) {
|
|
23
|
+
(0, node_opcua_assert_1.assert)(!this._hasEnded, "half communication channel has already ended !");
|
|
24
|
+
this._hasEnded = true;
|
|
25
|
+
this.emit("ending");
|
|
26
|
+
this.emit("end");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
destroy() {
|
|
30
|
+
}
|
|
31
|
+
setTimeout() {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.HalfComChannel = HalfComChannel;
|
|
35
|
+
//# sourceMappingURL=half_com_channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"half_com_channel.js","sourceRoot":"","sources":["../../test_helpers/half_com_channel.ts"],"names":[],"mappings":";;;AAAA,0BAA0B;AAC1B,iCAAiC;AACjC,mCAAsC;AACtC,yDAA2C;AAE3C,MAAa,cAAe,SAAQ,qBAAY;IAG5C;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,IAAqB;QAE9B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC1B,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC5B;QACD,IAAA,0BAAM,EAAC,IAAI,YAAY,MAAM,EAAE,yCAAyC,CAAC,CAAC;QAC1E,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IAEM,GAAG;QACN,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAA,0BAAM,EAAC,CAAC,IAAI,CAAC,SAAS,EAAE,gDAAgD,CAAC,CAAC;YAC1E,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACpB;IACL,CAAC;IAEM,OAAO;IACd,CAAC;IAEM,UAAU;IACjB,CAAC;CACJ;AAhCD,wCAgCC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./fake_server"), exports);
|
|
14
|
+
__exportStar(require("./direct_transport"), exports);
|
|
15
|
+
__exportStar(require("./socket_transport"), exports);
|
|
16
|
+
__exportStar(require("./half_com_channel"), exports);
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../test_helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA8B;AAC9B,qDAAmC;AACnC,qDAAmC;AACnC,qDAAmC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SocketTransport = void 0;
|
|
4
|
+
// tslint:disable:no-empty
|
|
5
|
+
const net = require("net");
|
|
6
|
+
const fake_server_1 = require("./fake_server");
|
|
7
|
+
class SocketTransport extends fake_server_1.FakeServer {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.client = new net.Socket();
|
|
11
|
+
this.client.connect(this.port, (err) => {
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
initialize(done) {
|
|
15
|
+
super.initialize(() => {
|
|
16
|
+
this.tcpServer.on("connection", (socket) => {
|
|
17
|
+
this.server = this._serverSocket;
|
|
18
|
+
done();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
shutdown(done) {
|
|
23
|
+
this.client.end();
|
|
24
|
+
super.shutdown((err) => {
|
|
25
|
+
done(err);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.SocketTransport = SocketTransport;
|
|
30
|
+
//# sourceMappingURL=socket_transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket_transport.js","sourceRoot":"","sources":["../../test_helpers/socket_transport.ts"],"names":[],"mappings":";;;AAAA,0BAA0B;AAC1B,2BAA4B;AAC5B,+CAA2C;AAE3C,MAAa,eAAgB,SAAQ,wBAAU;IAK3C;QAEI,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE;QAC/C,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,UAAU,CAAC,IAAgB;QAC9B,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE;YAClB,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,MAAkB,EAAE,EAAE;gBACnD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC;gBACjC,IAAI,EAAE,CAAC;YACX,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,QAAQ,CAAC,IAA2B;QACvC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAClB,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAW,EAAE,EAAE;YAC3B,IAAI,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA7BD,0CA6BC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-opcua-transport",
|
|
3
|
+
"version": "2.51.0",
|
|
4
|
+
"description": "pure nodejs OPCUA SDK - module -transport",
|
|
5
|
+
"main": "./dist/source/index.js",
|
|
6
|
+
"types": "./dist/source/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -b",
|
|
9
|
+
"test": "mocha",
|
|
10
|
+
"clean": "node -e \"require('rimraf').sync('dist');\""
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"chalk": "4.1.2",
|
|
14
|
+
"node-opcua-assert": "2.51.0",
|
|
15
|
+
"node-opcua-basic-types": "2.51.0",
|
|
16
|
+
"node-opcua-binary-stream": "2.51.0",
|
|
17
|
+
"node-opcua-buffer-utils": "2.51.0",
|
|
18
|
+
"node-opcua-chunkmanager": "2.51.0",
|
|
19
|
+
"node-opcua-debug": "2.51.0",
|
|
20
|
+
"node-opcua-factory": "2.51.0",
|
|
21
|
+
"node-opcua-nodeid": "2.51.0",
|
|
22
|
+
"node-opcua-object-registry": "2.51.0",
|
|
23
|
+
"node-opcua-packet-assembler": "2.51.0",
|
|
24
|
+
"node-opcua-status-code": "2.51.0",
|
|
25
|
+
"node-opcua-types": "2.51.0",
|
|
26
|
+
"node-opcua-utils": "2.51.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "16.7.10",
|
|
30
|
+
"node-opcua-debug": "2.42.0",
|
|
31
|
+
"should": "^13.2.3",
|
|
32
|
+
"sinon": "^11.1.2"
|
|
33
|
+
},
|
|
34
|
+
"author": "Etienne Rossignon",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git://github.com/node-opcua/node-opcua.git"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"OPCUA",
|
|
42
|
+
"opcua",
|
|
43
|
+
"m2m",
|
|
44
|
+
"iot",
|
|
45
|
+
"opc ua",
|
|
46
|
+
"internet of things"
|
|
47
|
+
],
|
|
48
|
+
"homepage": "http://node-opcua.github.io/",
|
|
49
|
+
"gitHead": "75feb111daf7ec65fa0111e4fa5beb8987fd4945"
|
|
50
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-transport
|
|
3
|
+
*/
|
|
4
|
+
import { decodeUInt32, encodeUInt32, UInt32 } from "node-opcua-basic-types";
|
|
5
|
+
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
6
|
+
import {
|
|
7
|
+
BaseUAObject,
|
|
8
|
+
buildStructuredType, check_options_correctness_against_schema,
|
|
9
|
+
initialize_field,
|
|
10
|
+
parameters,
|
|
11
|
+
StructuredTypeSchema
|
|
12
|
+
} from "node-opcua-factory";
|
|
13
|
+
|
|
14
|
+
const schemaAcknowledgeMessage: StructuredTypeSchema = buildStructuredType({
|
|
15
|
+
name: "AcknowledgeMessage",
|
|
16
|
+
|
|
17
|
+
baseType: "BaseObjectType",
|
|
18
|
+
|
|
19
|
+
fields: [
|
|
20
|
+
{
|
|
21
|
+
name: "protocolVersion",
|
|
22
|
+
|
|
23
|
+
fieldType: "UInt32",
|
|
24
|
+
|
|
25
|
+
documentation: "The latest version of the OPC UA TCP protocol supported by the Server."
|
|
26
|
+
},
|
|
27
|
+
{ name: "receiveBufferSize", fieldType: "UInt32" },
|
|
28
|
+
{ name: "sendBufferSize", fieldType: "UInt32" },
|
|
29
|
+
{ name: "maxMessageSize", fieldType: "UInt32", documentation: "The maximum size for any request message." },
|
|
30
|
+
{
|
|
31
|
+
name: "maxChunkCount",
|
|
32
|
+
|
|
33
|
+
fieldType: "UInt32",
|
|
34
|
+
|
|
35
|
+
documentation: "The maximum number of chunks in any request message."
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
interface AcknowledgeMessageOptions {
|
|
41
|
+
protocolVersion?: UInt32;
|
|
42
|
+
receiveBufferSize?: UInt32;
|
|
43
|
+
sendBufferSize?: UInt32;
|
|
44
|
+
maxMessageSize?: UInt32;
|
|
45
|
+
maxChunkCount?: UInt32;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class AcknowledgeMessage extends BaseUAObject {
|
|
49
|
+
|
|
50
|
+
public static possibleFields: string[] = [
|
|
51
|
+
"protocolVersion",
|
|
52
|
+
"receiveBufferSize",
|
|
53
|
+
"sendBufferSize",
|
|
54
|
+
"maxMessageSize",
|
|
55
|
+
"maxChunkCount"
|
|
56
|
+
];
|
|
57
|
+
public static schema = schemaAcknowledgeMessage;
|
|
58
|
+
|
|
59
|
+
public protocolVersion: UInt32;
|
|
60
|
+
public receiveBufferSize: UInt32;
|
|
61
|
+
public sendBufferSize: UInt32;
|
|
62
|
+
public maxMessageSize: UInt32;
|
|
63
|
+
public maxChunkCount: UInt32;
|
|
64
|
+
|
|
65
|
+
constructor(options?: AcknowledgeMessageOptions) {
|
|
66
|
+
|
|
67
|
+
options = options || {};
|
|
68
|
+
|
|
69
|
+
super();
|
|
70
|
+
const schema = schemaAcknowledgeMessage;
|
|
71
|
+
/* istanbul ignore next */
|
|
72
|
+
if (parameters.debugSchemaHelper) {
|
|
73
|
+
check_options_correctness_against_schema(this, schema, options);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.protocolVersion = initialize_field(schema.fields[0], options.protocolVersion);
|
|
77
|
+
this.receiveBufferSize = initialize_field(schema.fields[1], options.receiveBufferSize);
|
|
78
|
+
this.sendBufferSize = initialize_field(schema.fields[2], options.sendBufferSize);
|
|
79
|
+
this.maxMessageSize = initialize_field(schema.fields[3], options.maxMessageSize);
|
|
80
|
+
this.maxChunkCount = initialize_field(schema.fields[4], options.maxChunkCount);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public encode(stream: OutputBinaryStream): void {
|
|
84
|
+
|
|
85
|
+
super.encode(stream);
|
|
86
|
+
encodeUInt32(this.protocolVersion, stream);
|
|
87
|
+
encodeUInt32(this.receiveBufferSize, stream);
|
|
88
|
+
encodeUInt32(this.sendBufferSize, stream);
|
|
89
|
+
encodeUInt32(this.maxMessageSize, stream);
|
|
90
|
+
encodeUInt32(this.maxChunkCount, stream);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public decode(stream: BinaryStream): void {
|
|
94
|
+
// call base class implementation first
|
|
95
|
+
super.decode(stream);
|
|
96
|
+
this.protocolVersion = decodeUInt32(stream);
|
|
97
|
+
this.receiveBufferSize = decodeUInt32(stream);
|
|
98
|
+
this.sendBufferSize = decodeUInt32(stream);
|
|
99
|
+
this.maxMessageSize = decodeUInt32(stream);
|
|
100
|
+
this.maxChunkCount = decodeUInt32(stream);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public toString(): string {
|
|
104
|
+
let str = "";
|
|
105
|
+
str += 'protocolVersion = ' + this.protocolVersion +'\n';
|
|
106
|
+
str += 'receiveBufferSize = ' + this.receiveBufferSize +'\n';
|
|
107
|
+
str += 'sendBufferSize = ' + this.sendBufferSize +'\n';
|
|
108
|
+
str += 'maxMessageSize = ' + this.maxMessageSize +'\n';
|
|
109
|
+
str += 'maxChunkCount = ' + this.maxChunkCount +'\n';
|
|
110
|
+
return str;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-transport
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
decodeUAString, decodeUInt32, encodeUAString,
|
|
6
|
+
encodeUInt32, UAString, UInt32
|
|
7
|
+
} from "node-opcua-basic-types";
|
|
8
|
+
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
9
|
+
import {
|
|
10
|
+
BaseUAObject,
|
|
11
|
+
buildStructuredType, check_options_correctness_against_schema,
|
|
12
|
+
initialize_field,
|
|
13
|
+
parameters, StructuredTypeSchema
|
|
14
|
+
} from "node-opcua-factory";
|
|
15
|
+
|
|
16
|
+
const schemaHelloMessage: StructuredTypeSchema = buildStructuredType({
|
|
17
|
+
name: "HelloMessage",
|
|
18
|
+
|
|
19
|
+
baseType: "BaseUAObject",
|
|
20
|
+
|
|
21
|
+
fields: [
|
|
22
|
+
{
|
|
23
|
+
name: "protocolVersion",
|
|
24
|
+
|
|
25
|
+
fieldType: "UInt32",
|
|
26
|
+
|
|
27
|
+
documentation: "The latest version of the OPC UA TCP protocol supported by the Client"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "receiveBufferSize",
|
|
31
|
+
|
|
32
|
+
fieldType: "UInt32",
|
|
33
|
+
|
|
34
|
+
documentation: "The largest message that the sender can receive."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "sendBufferSize",
|
|
38
|
+
|
|
39
|
+
fieldType: "UInt32",
|
|
40
|
+
|
|
41
|
+
documentation: "The largest message that the sender will send."
|
|
42
|
+
},
|
|
43
|
+
{ name: "maxMessageSize", fieldType: "UInt32", documentation: "The maximum size for any response message." },
|
|
44
|
+
{
|
|
45
|
+
name: "maxChunkCount",
|
|
46
|
+
|
|
47
|
+
fieldType: "UInt32",
|
|
48
|
+
|
|
49
|
+
documentation: "The maximum number of chunks in any response message"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "endpointUrl",
|
|
53
|
+
|
|
54
|
+
fieldType: "UAString",
|
|
55
|
+
|
|
56
|
+
documentation: "The URL of the Endpoint which the Client wished to connect to."
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export interface HelloMessageOptions {
|
|
62
|
+
protocolVersion?: UInt32;
|
|
63
|
+
receiveBufferSize?: UInt32;
|
|
64
|
+
sendBufferSize?: UInt32;
|
|
65
|
+
maxMessageSize?: UInt32;
|
|
66
|
+
maxChunkCount?: UInt32;
|
|
67
|
+
endpointUrl?: UAString;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export class HelloMessage extends BaseUAObject {
|
|
71
|
+
|
|
72
|
+
public static possibleFields: string[] = [
|
|
73
|
+
"protocolVersion",
|
|
74
|
+
"receiveBufferSize",
|
|
75
|
+
"sendBufferSize",
|
|
76
|
+
"maxMessageSize",
|
|
77
|
+
"maxChunkCount",
|
|
78
|
+
"endpointUrl"
|
|
79
|
+
];
|
|
80
|
+
public protocolVersion: UInt32;
|
|
81
|
+
public receiveBufferSize: UInt32;
|
|
82
|
+
public sendBufferSize: UInt32;
|
|
83
|
+
public maxMessageSize: UInt32;
|
|
84
|
+
public maxChunkCount: UInt32;
|
|
85
|
+
public endpointUrl: UAString;
|
|
86
|
+
|
|
87
|
+
constructor(options?: HelloMessageOptions) {
|
|
88
|
+
options = options || {};
|
|
89
|
+
super();
|
|
90
|
+
const schema = schemaHelloMessage;
|
|
91
|
+
/* istanbul ignore next */
|
|
92
|
+
if (parameters.debugSchemaHelper) {
|
|
93
|
+
check_options_correctness_against_schema(this, schema, options);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.protocolVersion = initialize_field(schema.fields[0], options.protocolVersion);
|
|
97
|
+
this.receiveBufferSize = initialize_field(schema.fields[1], options.receiveBufferSize);
|
|
98
|
+
this.sendBufferSize = initialize_field(schema.fields[2], options.sendBufferSize);
|
|
99
|
+
this.maxMessageSize = initialize_field(schema.fields[3], options.maxMessageSize);
|
|
100
|
+
this.maxChunkCount = initialize_field(schema.fields[4], options.maxChunkCount);
|
|
101
|
+
this.endpointUrl = initialize_field(schema.fields[5], options.endpointUrl);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public encode(stream: OutputBinaryStream): void {
|
|
105
|
+
super.encode(stream);
|
|
106
|
+
encodeUInt32(this.protocolVersion, stream);
|
|
107
|
+
encodeUInt32(this.receiveBufferSize, stream);
|
|
108
|
+
encodeUInt32(this.sendBufferSize, stream);
|
|
109
|
+
encodeUInt32(this.maxMessageSize, stream);
|
|
110
|
+
encodeUInt32(this.maxChunkCount, stream);
|
|
111
|
+
encodeUAString(this.endpointUrl, stream);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public decode(stream: BinaryStream): void {
|
|
115
|
+
super.decode(stream);
|
|
116
|
+
this.protocolVersion = decodeUInt32(stream);
|
|
117
|
+
this.receiveBufferSize = decodeUInt32(stream);
|
|
118
|
+
this.sendBufferSize = decodeUInt32(stream);
|
|
119
|
+
this.maxMessageSize = decodeUInt32(stream);
|
|
120
|
+
this.maxChunkCount = decodeUInt32(stream);
|
|
121
|
+
this.endpointUrl = decodeUAString(stream);
|
|
122
|
+
}
|
|
123
|
+
public toString() {
|
|
124
|
+
let str = "";
|
|
125
|
+
str += 'protocolVersion = ' + this.protocolVersion +'\n';
|
|
126
|
+
str += 'receiveBufferSize = ' + this.receiveBufferSize +'\n';
|
|
127
|
+
str += 'sendBufferSize = ' + this.sendBufferSize +'\n';
|
|
128
|
+
str += 'maxMessageSize = ' + this.maxMessageSize +'\n';
|
|
129
|
+
str += 'maxChunkCount = ' + this.maxChunkCount +'\n';
|
|
130
|
+
str += 'endpointUrl = ' + this.endpointUrl +'\n';
|
|
131
|
+
return str;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-transport
|
|
3
|
+
*/
|
|
4
|
+
import { decodeString, encodeString, UAString } from "node-opcua-basic-types";
|
|
5
|
+
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
6
|
+
import {
|
|
7
|
+
BaseUAObject,
|
|
8
|
+
buildStructuredType, check_options_correctness_against_schema,
|
|
9
|
+
initialize_field,
|
|
10
|
+
parameters
|
|
11
|
+
} from "node-opcua-factory";
|
|
12
|
+
import { decodeStatusCode, encodeStatusCode, StatusCode } from "node-opcua-status-code";
|
|
13
|
+
|
|
14
|
+
// TCP Error Message OPC Unified Architecture, Part 6 page 46
|
|
15
|
+
// the server always close the connection after sending the TCPError message
|
|
16
|
+
const schemaTCPErrorMessage = buildStructuredType({
|
|
17
|
+
name: "TCPErrorMessage",
|
|
18
|
+
|
|
19
|
+
baseType: "BaseUAObject",
|
|
20
|
+
|
|
21
|
+
fields: [
|
|
22
|
+
{name: "statusCode", fieldType: "StatusCode"},
|
|
23
|
+
{name: "reason", fieldType: "String"} // A more verbose description of the error.
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export class TCPErrorMessage extends BaseUAObject {
|
|
28
|
+
public static possibleFields: string[] = ["statusCode", "reason"];
|
|
29
|
+
public statusCode: StatusCode;
|
|
30
|
+
public reason: UAString;
|
|
31
|
+
constructor(options?: { statusCode?: StatusCode, reason?: string}) {
|
|
32
|
+
options = options || {};
|
|
33
|
+
const schema = schemaTCPErrorMessage;
|
|
34
|
+
|
|
35
|
+
super();
|
|
36
|
+
/* istanbul ignore next */
|
|
37
|
+
if (parameters.debugSchemaHelper) {
|
|
38
|
+
check_options_correctness_against_schema(this, schema, options);
|
|
39
|
+
}
|
|
40
|
+
this.statusCode = initialize_field(schema.fields[0], options.statusCode);
|
|
41
|
+
this.reason = initialize_field(schema.fields[1], options.reason);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public encode(stream: OutputBinaryStream): void {
|
|
45
|
+
// call base class implementation first
|
|
46
|
+
super.encode(stream);
|
|
47
|
+
encodeStatusCode(this.statusCode, stream);
|
|
48
|
+
encodeString(this.reason, stream);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public decode(stream: BinaryStream): void {
|
|
52
|
+
// call base class implementation first
|
|
53
|
+
super.decode(stream);
|
|
54
|
+
this.statusCode = decodeStatusCode(stream);
|
|
55
|
+
this.reason = decodeString(stream);
|
|
56
|
+
}
|
|
57
|
+
}
|