node-opcua-transport 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.
Files changed (55) hide show
  1. package/package.json +13 -13
  2. package/dist/source/AcknowledgeMessage.d.ts +0 -27
  3. package/dist/source/AcknowledgeMessage.js +0 -79
  4. package/dist/source/AcknowledgeMessage.js.map +0 -1
  5. package/dist/source/HelloMessage.d.ts +0 -27
  6. package/dist/source/HelloMessage.js +0 -95
  7. package/dist/source/HelloMessage.js.map +0 -1
  8. package/dist/source/TCPErrorMessage.d.ts +0 -18
  9. package/dist/source/TCPErrorMessage.js +0 -47
  10. package/dist/source/TCPErrorMessage.js.map +0 -1
  11. package/dist/source/client_tcp_transport.d.ts +0 -87
  12. package/dist/source/client_tcp_transport.js +0 -335
  13. package/dist/source/client_tcp_transport.js.map +0 -1
  14. package/dist/source/index.d.ts +0 -13
  15. package/dist/source/index.js +0 -30
  16. package/dist/source/index.js.map +0 -1
  17. package/dist/source/message_builder_base.d.ts +0 -112
  18. package/dist/source/message_builder_base.js +0 -245
  19. package/dist/source/message_builder_base.js.map +0 -1
  20. package/dist/source/server_tcp_transport.d.ts +0 -44
  21. package/dist/source/server_tcp_transport.js +0 -233
  22. package/dist/source/server_tcp_transport.js.map +0 -1
  23. package/dist/source/status_codes.d.ts +0 -100
  24. package/dist/source/status_codes.js +0 -111
  25. package/dist/source/status_codes.js.map +0 -1
  26. package/dist/source/tcp_transport.d.ts +0 -136
  27. package/dist/source/tcp_transport.js +0 -380
  28. package/dist/source/tcp_transport.js.map +0 -1
  29. package/dist/source/tools.d.ts +0 -14
  30. package/dist/source/tools.js +0 -104
  31. package/dist/source/tools.js.map +0 -1
  32. package/dist/source/utils.d.ts +0 -3
  33. package/dist/source/utils.js +0 -10
  34. package/dist/source/utils.js.map +0 -1
  35. package/dist/test-fixtures/fixture_full_tcp_packets.d.ts +0 -21
  36. package/dist/test-fixtures/fixture_full_tcp_packets.js +0 -413
  37. package/dist/test-fixtures/fixture_full_tcp_packets.js.map +0 -1
  38. package/dist/test-fixtures/index.d.ts +0 -1
  39. package/dist/test-fixtures/index.js +0 -18
  40. package/dist/test-fixtures/index.js.map +0 -1
  41. package/dist/test_helpers/direct_transport.d.ts +0 -18
  42. package/dist/test_helpers/direct_transport.js +0 -63
  43. package/dist/test_helpers/direct_transport.js.map +0 -1
  44. package/dist/test_helpers/fake_server.d.ts +0 -19
  45. package/dist/test_helpers/fake_server.js +0 -55
  46. package/dist/test_helpers/fake_server.js.map +0 -1
  47. package/dist/test_helpers/half_com_channel.d.ts +0 -17
  48. package/dist/test_helpers/half_com_channel.js +0 -32
  49. package/dist/test_helpers/half_com_channel.js.map +0 -1
  50. package/dist/test_helpers/index.d.ts +0 -4
  51. package/dist/test_helpers/index.js +0 -21
  52. package/dist/test_helpers/index.js.map +0 -1
  53. package/dist/test_helpers/socket_transport.d.ts +0 -10
  54. package/dist/test_helpers/socket_transport.js +0 -31
  55. package/dist/test_helpers/socket_transport.js.map +0 -1
@@ -1,335 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientTCP_transport = void 0;
4
- /**
5
- * @module node-opcua-transport
6
- */
7
- const os = require("os");
8
- const net_1 = require("net");
9
- const chalk = require("chalk");
10
- const node_opcua_assert_1 = require("node-opcua-assert");
11
- const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
12
- const node_opcua_chunkmanager_1 = require("node-opcua-chunkmanager");
13
- const debug = require("node-opcua-debug");
14
- const tcp_transport_1 = require("./tcp_transport");
15
- const tools_1 = require("./tools");
16
- const AcknowledgeMessage_1 = require("./AcknowledgeMessage");
17
- const HelloMessage_1 = require("./HelloMessage");
18
- const TCPErrorMessage_1 = require("./TCPErrorMessage");
19
- const utils_1 = require("./utils");
20
- const doDebug = debug.checkDebugFlag(__filename);
21
- const debugLog = debug.make_debugLog(__filename);
22
- const warningLog = debug.make_warningLog(__filename);
23
- const errorLog = debug.make_errorLog(__filename);
24
- const gHostname = os.hostname();
25
- function createClientSocket(endpointUrl) {
26
- // create a socket based on Url
27
- const ep = (0, tools_1.parseEndpointUrl)(endpointUrl);
28
- const port = parseInt(ep.port, 10);
29
- const hostname = ep.hostname;
30
- let socket;
31
- switch (ep.protocol) {
32
- case "opc.tcp:":
33
- socket = (0, net_1.createConnection)({ host: hostname, port });
34
- socket.setKeepAlive(true);
35
- // Setting true for noDelay will immediately fire off data each time socket.write() is called.
36
- socket.setNoDelay(true);
37
- return socket;
38
- case "fake:":
39
- socket = (0, tcp_transport_1.getFakeTransport)();
40
- (0, node_opcua_assert_1.assert)(ep.protocol === "fake:", " Unsupported transport protocol");
41
- process.nextTick(() => socket.emit("connect"));
42
- return socket;
43
- case "websocket:":
44
- case "http:":
45
- case "https:FF":
46
- default: {
47
- const msg = "[NODE-OPCUA-E05] this transport protocol is not supported :" + ep.protocol;
48
- errorLog(msg);
49
- throw new Error(msg);
50
- }
51
- }
52
- }
53
- /**
54
- * a ClientTCP_transport connects to a remote server socket and
55
- * initiates a communication with a HEL/ACK transaction.
56
- * It negotiates the communication parameters with the other end.
57
- *
58
- * @class ClientTCP_transport
59
- * @extends TCP_transport
60
- * @constructor
61
- * @example
62
- *
63
- * ```javascript
64
- * const transport = ClientTCP_transport(url);
65
- *
66
- * transport.timeout = 10000;
67
- *
68
- * transport.connect(function(err)) {
69
- * if (err) {
70
- * // cannot connect
71
- * } else {
72
- * // connected
73
- *
74
- * }
75
- * });
76
- * ....
77
- *
78
- * transport.write(message_chunk,'F');
79
- *
80
- * ....
81
- *
82
- * transport.on("chunk",function(message_chunk) {
83
- * // do something with chunk from server...
84
- * });
85
- *
86
- *
87
- * ```
88
- *
89
- *
90
- */
91
- class ClientTCP_transport extends tcp_transport_1.TCP_transport {
92
- constructor(transportSettings) {
93
- super();
94
- this.connected = false;
95
- this.endpointUrl = "";
96
- this.serverUri = "";
97
- this._counter = 0;
98
- this.numberOfRetry = 0;
99
- // initially before HEL/ACK
100
- this.maxChunkCount = 1;
101
- this.maxMessageSize = 4 * 1024;
102
- this.receiveBufferSize = 4 * 1024;
103
- transportSettings = transportSettings || {};
104
- this._helloSettings = {
105
- maxChunkCount: transportSettings.maxChunkCount || ClientTCP_transport.defaultMaxChunk,
106
- maxMessageSize: transportSettings.maxMessageSize || ClientTCP_transport.defaultMaxMessageSize,
107
- receiveBufferSize: transportSettings.receiveBufferSize || ClientTCP_transport.defaultReceiveBufferSize,
108
- sendBufferSize: transportSettings.sendBufferSize || ClientTCP_transport.defaultSendBufferSize
109
- };
110
- }
111
- getTransportSettings() {
112
- return this._helloSettings;
113
- }
114
- dispose() {
115
- /* istanbul ignore next */
116
- if (doDebug) {
117
- debugLog(" ClientTCP_transport disposed");
118
- }
119
- super.dispose();
120
- }
121
- connect(endpointUrl, callback) {
122
- (0, node_opcua_assert_1.assert)(arguments.length === 2);
123
- (0, node_opcua_assert_1.assert)(typeof callback === "function");
124
- const ep = (0, tools_1.parseEndpointUrl)(endpointUrl);
125
- this.endpointUrl = endpointUrl;
126
- this.serverUri = "urn:" + gHostname + ":Sample";
127
- /* istanbul ignore next */
128
- if (doDebug) {
129
- debugLog(chalk.cyan("ClientTCP_transport#connect(endpointUrl = " + endpointUrl + ")"));
130
- }
131
- try {
132
- this._socket = createClientSocket(endpointUrl);
133
- }
134
- catch (err) {
135
- /* istanbul ignore next */
136
- if (doDebug) {
137
- debugLog("CreateClientSocket has failed");
138
- }
139
- return callback(err);
140
- }
141
- const _on_socket_error_after_connection = (err) => {
142
- /* istanbul ignore next */
143
- if (doDebug) {
144
- debugLog(" _on_socket_error_after_connection ClientTCP_transport Socket Error", err.message);
145
- }
146
- // EPIPE : EPIPE (Broken pipe): A write on a pipe, socket, or FIFO for which there is no process to read the
147
- // data. Commonly encountered at the net and http layers, indicative that the remote side of the stream
148
- // being written to has been closed.
149
- // ECONNRESET (Connection reset by peer): A connection was forcibly closed by a peer. This normally results
150
- // from a loss of the connection on the remote socket due to a timeout or reboot. Commonly encountered
151
- // via the http and net module
152
- if (err.message.match(/ECONNRESET|EPIPE/)) {
153
- /**
154
- * @event connection_break
155
- *
156
- */
157
- this.emit("connection_break");
158
- }
159
- };
160
- const _on_socket_connect = () => {
161
- /* istanbul ignore next */
162
- if (doDebug) {
163
- debugLog("entering _on_socket_connect");
164
- }
165
- _remove_connect_listeners();
166
- this._perform_HEL_ACK_transaction((err) => {
167
- if (!err) {
168
- /* istanbul ignore next */
169
- if (!this._socket) {
170
- throw new Error("internal error");
171
- }
172
- // install error handler to detect connection break
173
- this._socket.on("error", _on_socket_error_after_connection);
174
- this.connected = true;
175
- /**
176
- * notify the observers that the transport is connected (the socket is connected and the the HEL/ACK
177
- * transaction has been done)
178
- * @event connect
179
- *
180
- */
181
- this.emit("connect");
182
- }
183
- else {
184
- debugLog("_perform_HEL_ACK_transaction has failed with err=", err.message);
185
- }
186
- callback(err);
187
- });
188
- };
189
- const _on_socket_error_for_connect = (err) => {
190
- // this handler will catch attempt to connect to an inaccessible address.
191
- /* istanbul ignore next */
192
- if (doDebug) {
193
- debugLog(chalk.cyan("ClientTCP_transport#connect - _on_socket_error_for_connect"), err.message);
194
- }
195
- (0, node_opcua_assert_1.assert)(err instanceof Error);
196
- _remove_connect_listeners();
197
- callback(err);
198
- };
199
- const _on_socket_end_for_connect = (err) => {
200
- /* istanbul ignore next */
201
- if (doDebug) {
202
- debugLog(chalk.cyan("ClientTCP_transport#connect -> _on_socket_end_for_connect Socket has been closed by server"), err);
203
- }
204
- };
205
- const _remove_connect_listeners = () => {
206
- /* istanbul ignore next */
207
- if (!this._socket) {
208
- return;
209
- }
210
- this._socket.removeListener("error", _on_socket_error_for_connect);
211
- this._socket.removeListener("end", _on_socket_end_for_connect);
212
- };
213
- this._socket.once("error", _on_socket_error_for_connect);
214
- this._socket.once("end", _on_socket_end_for_connect);
215
- this._socket.once("connect", _on_socket_connect);
216
- this._install_socket(this._socket);
217
- }
218
- on_socket_ended(err) {
219
- debugLog("on_socket_ended", this.name, err ? err.message : "");
220
- if (this.connected) {
221
- super.on_socket_ended(err);
222
- }
223
- // if (this._socket) {
224
- // this._socket.removeAllListeners();
225
- // }
226
- }
227
- _handle_ACK_response(messageChunk, callback) {
228
- const _stream = new node_opcua_binary_stream_1.BinaryStream(messageChunk);
229
- const messageHeader = (0, node_opcua_chunkmanager_1.readMessageHeader)(_stream);
230
- let err;
231
- /* istanbul ignore next */
232
- if (messageHeader.isFinal !== "F") {
233
- err = new Error(" invalid ACK message");
234
- return callback(err);
235
- }
236
- let responseClass;
237
- let response;
238
- if (messageHeader.msgType === "ERR") {
239
- responseClass = TCPErrorMessage_1.TCPErrorMessage;
240
- _stream.rewind();
241
- response = (0, tools_1.decodeMessage)(_stream, responseClass);
242
- err = new Error("ACK: ERR received " + response.statusCode.toString() + " : " + response.reason);
243
- err.statusCode = response.statusCode;
244
- // istanbul ignore next
245
- if (utils_1.doTraceHelloAck) {
246
- warningLog("receiving ERR instead of Ack", response.toString());
247
- }
248
- callback(err);
249
- }
250
- else {
251
- responseClass = AcknowledgeMessage_1.AcknowledgeMessage;
252
- _stream.rewind();
253
- response = (0, tools_1.decodeMessage)(_stream, responseClass);
254
- this.parameters = response;
255
- this.setLimits(response);
256
- // istanbul ignore next
257
- if (utils_1.doTraceHelloAck) {
258
- warningLog("receiving Ack\n", response.toString());
259
- }
260
- callback();
261
- }
262
- }
263
- _send_HELLO_request() {
264
- /* istanbul ignore next */
265
- if (doDebug) {
266
- debugLog("entering _send_HELLO_request");
267
- }
268
- (0, node_opcua_assert_1.assert)(this._socket);
269
- (0, node_opcua_assert_1.assert)(isFinite(this.protocolVersion));
270
- (0, node_opcua_assert_1.assert)(this.endpointUrl.length > 0, " expecting a valid endpoint url");
271
- const { maxChunkCount, maxMessageSize, receiveBufferSize, sendBufferSize } = this._helloSettings;
272
- // Write a message to the socket as soon as the client is connected,
273
- // the server will receive it as message from the client
274
- const helloMessage = new HelloMessage_1.HelloMessage({
275
- endpointUrl: this.endpointUrl,
276
- protocolVersion: this.protocolVersion,
277
- maxChunkCount,
278
- maxMessageSize,
279
- receiveBufferSize,
280
- sendBufferSize
281
- });
282
- // istanbul ignore next
283
- if (utils_1.doTraceHelloAck) {
284
- warningLog(`sending Hello\n ${helloMessage.toString()}`);
285
- }
286
- const messageChunk = (0, tools_1.packTcpMessage)("HEL", helloMessage);
287
- this._write_chunk(messageChunk);
288
- }
289
- _on_ACK_response(externalCallback, err, data) {
290
- /* istanbul ignore next */
291
- if (doDebug) {
292
- debugLog("entering _on_ACK_response");
293
- }
294
- (0, node_opcua_assert_1.assert)(typeof externalCallback === "function");
295
- (0, node_opcua_assert_1.assert)(this._counter === 0, "Ack response should only be received once !");
296
- this._counter += 1;
297
- if (err || !data) {
298
- externalCallback(err || new Error("no data"));
299
- if (this._socket) {
300
- this._socket.end();
301
- // Xx this._socket.removeAllListeners();
302
- }
303
- }
304
- else {
305
- this._handle_ACK_response(data, externalCallback);
306
- }
307
- }
308
- _perform_HEL_ACK_transaction(callback) {
309
- /* istanbul ignore next */
310
- if (!this._socket) {
311
- return callback(new Error("No socket available to perform HEL/ACK transaction"));
312
- }
313
- (0, node_opcua_assert_1.assert)(this._socket, "expecting a valid socket to send a message");
314
- (0, node_opcua_assert_1.assert)(typeof callback === "function");
315
- this._counter = 0;
316
- /* istanbul ignore next */
317
- if (doDebug) {
318
- debugLog("entering _perform_HEL_ACK_transaction");
319
- }
320
- this._install_one_time_message_receiver((err, data) => {
321
- /* istanbul ignore next */
322
- if (doDebug) {
323
- debugLog("before _on_ACK_response ", err ? err.message : "");
324
- }
325
- this._on_ACK_response(callback, err, data);
326
- });
327
- this._send_HELLO_request();
328
- }
329
- }
330
- exports.ClientTCP_transport = ClientTCP_transport;
331
- ClientTCP_transport.defaultMaxChunk = 0; // 0 - no limits
332
- ClientTCP_transport.defaultMaxMessageSize = 0; // 0 - no limits
333
- ClientTCP_transport.defaultReceiveBufferSize = 1024 * 64 * 10;
334
- ClientTCP_transport.defaultSendBufferSize = 1024 * 64 * 10; // 8192 min,
335
- //# sourceMappingURL=client_tcp_transport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client_tcp_transport.js","sourceRoot":"","sources":["../../source/client_tcp_transport.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yBAAyB;AACzB,6BAA+C;AAC/C,+BAA+B;AAE/B,yDAA2C;AAC3C,uEAAwD;AACxD,qEAA4D;AAG5D,0CAA0C;AAC1C,mDAAkE;AAClE,mCAA0E;AAE1E,6DAA0D;AAC1D,iDAA8C;AAC9C,uDAAoD;AACpD,mCAA0C;AAE1C,MAAM,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;AACjD,MAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACjD,MAAM,UAAU,GAAG,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;AACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACjD,MAAM,SAAS,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AAEhC,SAAS,kBAAkB,CAAC,WAAmB;IAC3C,+BAA+B;IAC/B,MAAM,EAAE,GAAG,IAAA,wBAAgB,EAAC,WAAW,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,CAAC,IAAK,EAAE,EAAE,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAS,CAAC;IAC9B,IAAI,MAAc,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE;QACjB,KAAK,UAAU;YACX,MAAM,GAAG,IAAA,sBAAgB,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;YAEpD,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAE1B,8FAA8F;YAC9F,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAExB,OAAO,MAAM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,CAAC,CAAC,gBAAgB;AACrC,yCAAqB,GAAG,CAAC,CAAC,CAAC,gBAAgB;AAC3C,4CAAwB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1C,yCAAqB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,YAAY"}
@@ -1,13 +0,0 @@
1
- /**
2
- * @module node-opcua-transport
3
- */
4
- export * from "./AcknowledgeMessage";
5
- export * from "./client_tcp_transport";
6
- export * from "./HelloMessage";
7
- export * from "./message_builder_base";
8
- export * from "./server_tcp_transport";
9
- export * from "./status_codes";
10
- export * from "./tcp_transport";
11
- export * from "./TCPErrorMessage";
12
- export * from "./tools";
13
- export * from "./utils";
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- /**
18
- * @module node-opcua-transport
19
- */
20
- __exportStar(require("./AcknowledgeMessage"), exports);
21
- __exportStar(require("./client_tcp_transport"), exports);
22
- __exportStar(require("./HelloMessage"), exports);
23
- __exportStar(require("./message_builder_base"), exports);
24
- __exportStar(require("./server_tcp_transport"), exports);
25
- __exportStar(require("./status_codes"), exports);
26
- __exportStar(require("./tcp_transport"), exports);
27
- __exportStar(require("./TCPErrorMessage"), exports);
28
- __exportStar(require("./tools"), exports);
29
- __exportStar(require("./utils"), exports);
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,uDAAqC;AACrC,yDAAuC;AACvC,iDAA+B;AAC/B,yDAAuC;AACvC,yDAAuC;AACvC,iDAA+B;AAC/B,kDAAgC;AAChC,oDAAkC;AAClC,0CAAwB;AACxB,0CAAwB"}
@@ -1,112 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /**
4
- * @module node-opcua-transport
5
- */
6
- import { EventEmitter } from "events";
7
- import { BinaryStream } from "node-opcua-binary-stream";
8
- import { SequenceHeader } from "node-opcua-chunkmanager";
9
- import { MessageHeader, PacketAssembler, PacketInfo } from "node-opcua-packet-assembler";
10
- import { StatusCode } from "node-opcua-status-code";
11
- export declare function readRawMessageHeader(data: Buffer): PacketInfo;
12
- export interface MessageBuilderBaseOptions {
13
- signatureLength?: number;
14
- maxMessageSize?: number;
15
- maxChunkCount?: number;
16
- maxChunkSize?: number;
17
- }
18
- export interface MessageBuilderBase {
19
- /**
20
- *
21
- * notify the observers that a new message is being built
22
- * @event start_chunk
23
- * @param info
24
- * @param data
25
- */
26
- on(eventName: "startChunk", eventHandler: (info: PacketInfo, data: Buffer) => void): this;
27
- /**
28
- * notify the observers that new message chunk has been received
29
- * @event chunk
30
- * @param messageChunk the raw message chunk
31
- */
32
- on(eventName: "chunk", eventHandler: (chunk: Buffer) => void): this;
33
- /**
34
- * notify the observers that an error has occurred
35
- * @event error
36
- * @param error the error to raise
37
- */
38
- on(eventName: "error", eventHandler: (err: Error, statusCode: StatusCode, requestId: number | null) => void): this;
39
- /**
40
- * notify the observers that a full message has been received
41
- * @event full_message_body
42
- * @param full_message_body the full message body made of all concatenated chunks.
43
- */
44
- on(eventName: "full_message_body", eventHandler: (fullMessageBody: Buffer) => void): this;
45
- /**
46
- *
47
- * @param eventName "abandon"
48
- * @param info
49
- * @param data
50
- */
51
- on(eventName: "abandon", eventHandler: (requestId: number) => void): this;
52
- emit(eventName: "startChunk", info: PacketInfo, data: Buffer): boolean;
53
- emit(eventName: "chunk", chunk: Buffer): boolean;
54
- emit(eventName: "error", err: Error, statusCode: StatusCode, requestId: number | null): boolean;
55
- emit(eventName: "full_message_body", fullMessageBody: Buffer): boolean;
56
- emit(eventName: "abandon", requestId: number): boolean;
57
- }
58
- /**
59
- * @class MessageBuilderBase
60
- * @extends EventEmitter
61
- * @uses PacketAssembler
62
- * @constructor
63
- * @param options {Object}
64
- * @param [options.signatureLength=0] {number}
65
- *
66
- */
67
- export declare class MessageBuilderBase extends EventEmitter {
68
- static defaultMaxChunkCount: number;
69
- static defaultMaxMessageSize: number;
70
- static defaultMaxChunkSize: number;
71
- readonly signatureLength: number;
72
- readonly maxMessageSize: number;
73
- readonly maxChunkCount: number;
74
- readonly maxChunkSize: number;
75
- readonly options: MessageBuilderBaseOptions;
76
- readonly _packetAssembler: PacketAssembler;
77
- channelId: number;
78
- totalMessageSize: number;
79
- sequenceHeader: SequenceHeader | null;
80
- _tick0: number;
81
- _tick1: number;
82
- protected id: string;
83
- protected totalBodySize: number;
84
- protected messageChunks: Buffer[];
85
- protected messageHeader?: MessageHeader;
86
- private _securityDefeated;
87
- private _hasReceivedError;
88
- private blocks;
89
- private readonly _expectedChannelId;
90
- private offsetBodyStart;
91
- constructor(options?: MessageBuilderBaseOptions);
92
- dispose(): void;
93
- /**
94
- * Feed message builder with some data
95
- * @method feed
96
- * @param data
97
- */
98
- feed(data: Buffer): void;
99
- protected _decodeMessageBody(fullMessageBody: Buffer): boolean;
100
- protected _read_headers(binaryStream: BinaryStream): boolean;
101
- protected _report_abandon(channelId: number, tokenId: number, sequenceHeader: SequenceHeader): false;
102
- protected _report_error(statusCode: StatusCode, errorMessage: string): false;
103
- private _init_new;
104
- /**
105
- * append a message chunk
106
- * @method _append
107
- * @param chunk
108
- * @private
109
- */
110
- private _append;
111
- private _feed_messageChunk;
112
- }