Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _send_chunk(callback: ErrorCallback | undefined, messageChunk: Buffer | null) {
if (messageChunk) {
this.transport.write(messageChunk);
} else {
if (doPerfMonitoring) {
// record tick 3 : transaction completed.
this._tick3 = get_clock_tick();
}
if (callback) {
setImmediate(callback);
}
if (doPerfMonitoring) {
this._record_transaction_statistics();
/* istanbul ignore next */
if (doDebug) {
// dump some statistics about transaction ( time and sizes )
_dump_transaction_statistics(this.last_transaction_stats);
}
}
this.emit("transaction_done");
this._packetAssembler.on("newMessage", (info, data) => {
if (doPerfMonitoring) {
// record tick 0: when the first data is received
this._tick0 = get_clock_tick();
}
/**
*
* notify the observers that a new message is being built
* @event start_chunk
* @param info
* @param data
*/
this.emit("start_chunk", info, data);
});
_tick1: 0,
_tick2: 0,
_tick3: 0,
_tick4: 0,
key: "",
chunk_count: 0
};
this._requests[requestHandle] = requestData;
/* istanbul ignore next */
if (doPerfMonitoring) {
const stats = requestData;
// record tick0 : before request is being sent to server
stats._tick0 = get_clock_tick();
}
this._sendSecureOpcUARequest(msgType, request, requestHandle);
}
// istanbul ignore next
if (doDebug) {
assert(response.schema);
assert(request.schema);
assert(requestId > 0);
// verify that response for a given requestId is only sent once.
if (!this.__verifId) {
this.__verifId = {};
}
assert(!this.__verifId[requestId], " response for requestId has already been sent !! - Internal Error");
this.__verifId[requestId] = requestId;
}
if (doPerfMonitoring) {
// record tick : send response received.
this._tick2 = get_clock_tick();
}
assert(this.securityToken);
let options = {
channelId: this.securityToken.channelId,
chunkSize: this.transport.receiveBufferSize,
requestId,
tokenId: this.securityToken.tokenId
};
const securityOptions =
msgType === "OPN" ? this._get_security_options_for_OPN() : this._get_security_options_for_MSG();
options = _.extend(options, securityOptions);
response.responseHeader.requestHandle = request.requestHeader.requestHandle;
.on("start_chunk", () => {
//
if (doPerfMonitoring) {
this._tick2 = get_clock_tick();
}
})
.on("error", (err, requestId) => {
self.messageBuilder.on("message", _on_common_message.bind(self)).on("start_chunk", function() {
if (doPerfMonitoring) {
//record tick 0: when the first chunk is received
self._tick0 = get_clock_tick();
}
});