How to use node-opcua-packet-assembler - 4 common examples

To help you get started, we’ve selected a few node-opcua-packet-assembler 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
this.id = "";

        this._tick0 = 0;
        this._tick1 = 0;
        this._hasReceivedError = false;
        this.blocks = [];
        this.messageChunks = [];
        this._expectedChannelId = 0;

        options = options || {};

        this.signatureLength = options.signatureLength || 0;

        this.options = options;

        this._packetAssembler = new PacketAssembler({
            minimumSizeInBytes: 0,
            readMessageFunc: readRawMessageHeader
        });

        this._packetAssembler.on("message", (messageChunk) => this._feed_messageChunk(messageChunk));

        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
github node-opcua / node-opcua / packages / node-opcua-transport / src / message_builder_base.js View on Github external
const MessageBuilderBase = function (options) {

    options = options || {};

    this.signatureLength = options.signatureLength || 0;

    this.options = options;

    this.packetAssembler = new PacketAssembler({readMessageFunc: readRawMessageHeader});

    const self = this;
    this.packetAssembler.on("message", function (messageChunk) {
        self._feed_messageChunk(messageChunk);
    });
    this.packetAssembler.on("newMessage", function (info, data) {

        if(doPerfMonitoring) {
            // record tick 0: when the first data is received
            self._tick0 = get_clock_tick();
        }
        /**
         *
         * notify the observers that a new message is being built
         * @event start_chunk
         * @param info
github node-opcua / node-opcua / packages / node-opcua-transport / src / tcp_transport.js View on Github external
TCP_transport.prototype._install_socket = function (socket) {

    assert(socket);
    const self = this;

    self.name = " Transport " + counter;
    counter += 1;

    self._socket = socket;

    // install packet assembler ...
    self.packetAssembler = new PacketAssembler({
        readMessageFunc: readRawMessageHeader,
        minimumSizeInBytes: self.headerSize
    });

    self.packetAssembler.on("message", function (message_chunk) {
        _on_message_received.call(self, message_chunk);
    });


    self._socket.on("data", function (data) {
        self.bytesRead += data.length;
        if (data.length > 0) {
            self.packetAssembler.feed(data);
        }

    }).on("close", function (had_error) {
github node-opcua / node-opcua / packages / node-opcua-transport / source / tcp_transport.ts View on Github external
protected _install_socket(socket: Socket) {

        assert(socket);
        this._socket = socket;
        if (doDebug) {
            debugLog("_install_socket ", this.name);
        }

        // install packet assembler ...
        this.packetAssembler = new PacketAssembler({
            readMessageFunc: readRawMessageHeader,

            minimumSizeInBytes: this.headerSize
        });

        /* istanbul ignore next */
        if (!this.packetAssembler) {
            throw new Error("Internal Error");
        }
        this.packetAssembler.on("message", (messageChunk: Buffer) => this._on_message_received(messageChunk));

        this._socket
            .on("data", (data: Buffer) => this._on_socket_data(data))
            .on("close", (hadError) => this._on_socket_close(hadError))
            .on("end", (err: Error) => this._on_socket_end(err))
            .on("error", (err: Error) => this._on_socket_error(err));

node-opcua-packet-assembler

pure nodejs OPCUA SDK - module packet-assembler

MIT
Latest version published 3 months ago

Package Health Score

86 / 100
Full package analysis

Popular node-opcua-packet-assembler functions