How to use the node-opcua-chunkmanager.readMessageHeader function in node-opcua-chunkmanager

To help you get started, we’ve selected a few node-opcua-chunkmanager examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-transport / source / message_builder_base.ts View on Github external
private _feed_messageChunk(chunk: Buffer) {
        assert(chunk);
        const messageHeader = readMessageHeader(new BinaryStream(chunk));
        /**
         * notify the observers that new message chunk has been received
         * @event chunk
         * @param messageChunk the raw message chunk
         */
        this.emit("chunk", chunk);

        if (messageHeader.isFinal === "F") {

            // last message
            this._append(chunk);
            if (this._hasReceivedError) {
                return false;
            }

            const fullMessageBody: Buffer = this.blocks.length === 1 ? this.blocks[0] : Buffer.concat(this.blocks);
github node-opcua / node-opcua / packages / node-opcua-transport / source / client_tcp_transport.ts View on Github external
private _handle_ACK_response(messageChunk: Buffer, callback: ErrorCallback) {

        const _stream = new BinaryStream(messageChunk);
        const messageHeader = readMessageHeader(_stream);
        let err;
        /* istanbul ignore next */
        if (messageHeader.isFinal !== "F") {
            err = new Error(" invalid ACK message");
            return callback(err);
        }

        let responseClass;
        let response;

        if (messageHeader.msgType === "ERR") {
            responseClass = TCPErrorMessage;
            _stream.rewind();
            response = decodeMessage(_stream, responseClass) as TCPErrorMessage;

            err = new Error("ACK: ERR received " + response.statusCode.toString() + " : " + response.reason);
github node-opcua / node-opcua / packages / node-opcua-secure-channel / src / client / client_secure_channel_layer.js View on Github external
ClientSecureChannelLayer.prototype._on_receive_message_chunk = function (message_chunk) {

    const self = this;

    /* istanbul ignore next */
    if (doDebug) {
        const _stream = new BinaryStream(message_chunk);
        const messageHeader = readMessageHeader(_stream);
        debugLog("CLIENT RECEIVED " + (JSON.stringify(messageHeader) + "").yellow);
        debugLog("\n" + hexDump(message_chunk).blue);
        debugLog(messageHeaderToString(message_chunk));
    }
    self.messageBuilder.feed(message_chunk);
};
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / client / client_secure_channel_layer.ts View on Github external
private _on_receive_message_chunk(messageChunk: Buffer) {

        /* istanbul ignore next */
        if (doDebug1) {
            const _stream = new BinaryStream(messageChunk);
            const messageHeader = readMessageHeader(_stream);
            debugLog("CLIENT RECEIVED " + chalk.yellow(JSON.stringify(messageHeader) + ""));
            debugLog("\n" + hexDump(messageChunk));
            debugLog(messageHeaderToString(messageChunk));
        }
        this.messageBuilder.feed(messageChunk);
    }
github node-opcua / node-opcua / packages / node-opcua-transport / source / message_builder_base.ts View on Github external
protected _read_headers(binaryStream: BinaryStream): boolean {

        this.messageHeader = readMessageHeader(binaryStream);
        assert(binaryStream.length === 8, "expecting message header to be 8 bytes");

        this.channelId = binaryStream.readUInt32();
        assert(binaryStream.length === 12);

        // verifying secure ChannelId
        if (this._expectedChannelId && this.channelId !== this._expectedChannelId) {
            return this._report_error("Invalid secure channel Id");
        }
        return true;
    }
github node-opcua / node-opcua / packages / node-opcua-transport / src / message_builder_base.js View on Github external
function readRawMessageHeader(data) {
    const messageHeader = readMessageHeader(new BinaryStream(data));
    return {
        length: messageHeader.length,
        messageHeader: messageHeader
    };
}
exports.readRawMessageHeader = readRawMessageHeader;
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / message_header_to_string.ts View on Github external
export function messageHeaderToString(messageChunk: Buffer): string {

    const stream = new BinaryStream(messageChunk);

    const messageHeader = readMessageHeader(stream);
    if (messageHeader.msgType === "ERR" || messageHeader.msgType === "HEL") {
        return messageHeader.msgType + " " + messageHeader.isFinal + " length   = " + messageHeader.length;
    }

    const securityHeader = chooseSecurityHeader(messageHeader.msgType);

    const sequenceHeader = new SequenceHeader();
    assert(stream.length === 8);

    const channelId = stream.readUInt32();
    securityHeader.decode(stream);
    sequenceHeader.decode(stream);

    const slice = messageChunk.slice(0, stream.length);

    return messageHeader.msgType + " " +

node-opcua-chunkmanager

pure nodejs OPCUA SDK - module chunkmanager

MIT
Latest version published 7 days ago

Package Health Score

83 / 100
Full package analysis