How to use node-opcua-buffer-utils - 6 common examples

To help you get started, we’ve selected a few node-opcua-buffer-utils 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
}

        // the start of the message body block
        const offsetBodyStart = binaryStream.length;

        // the end of the message body block
        const offsetBodyEnd = binaryStream.buffer.length;

        this.totalBodySize += (offsetBodyEnd - offsetBodyStart);
        this.offsetBodyStart = offsetBodyStart;

        // add message body to a queue
        // note : Buffer.slice create a shared memory !
        //        use Buffer.clone
        const sharedBuffer = chunk.slice(offsetBodyStart, offsetBodyEnd);
        const clonedBuffer = createFastUninitializedBuffer(sharedBuffer.length);

        sharedBuffer.copy(clonedBuffer, 0, 0);
        this.blocks.push(clonedBuffer);

        return true;
    }
github node-opcua / node-opcua / packages / node-opcua-transport / src / tools.js View on Github external
function packTcpMessage(msgType, encodableObject) {

    assert(is_valid_msg_type(msgType));

    const messageChunk = createFastUninitializedBuffer(encodableObject.binaryStoreSize() + 8);
    // encode encodeableObject in a packet
    const stream = new BinaryStream(messageChunk);
    encodeMessage(msgType, encodableObject, stream);

    return messageChunk;

}
github node-opcua / node-opcua / packages / node-opcua-transport / source / tools.ts View on Github external
export function packTcpMessage(msgType: string, encodableObject: BaseUAObject): Buffer {

    assert(is_valid_msg_type(msgType));

    const messageChunk = createFastUninitializedBuffer(encodableObject.binaryStoreSize() + 8);
    // encode encodeableObject in a packet
    const stream = new BinaryStream(messageChunk);
    encodeMessage(msgType, encodableObject, stream);

    return messageChunk;

}
github node-opcua / node-opcua / packages / node-opcua-basic-types / source / byte_string.ts View on Github external
export function randomByteString(value: any, len: number): ByteString {
    len = len || getRandomInt(1, 200);
    const b = createFastUninitializedBuffer(len);
    for (let i = 0; i < len; i++) {
        b.writeUInt8(getRandomInt(0, 255), i);
    }
    return b;
}
github node-opcua / node-opcua / packages / node-opcua-transport / source / tcp_transport.ts View on Github external
public createChunk(msgType: string, chunkType: string, length: number): Buffer {

        assert(msgType === "MSG");
        assert(this._pendingBuffer === undefined, "createChunk has already been called ( use write first)");

        const totalLength = length + this.headerSize;
        const buffer = createFastUninitializedBuffer(totalLength);
        writeTCPMessageHeader("MSG", chunkType, totalLength, buffer);

        this._pendingBuffer = buffer;

        return buffer;
    }
github node-opcua / node-opcua / packages / node-opcua-debug / source / makebuffer_from_trace.ts View on Github external
export function makebuffer_from_trace(func: string | Function): Buffer {
    if (typeof func === "string") {
        return makeBuffer(hexString(func as string));
    }
    return makeBuffer(hexString(inlineText(func)));
}

node-opcua-buffer-utils

pure nodejs OPCUA SDK - module buffer-utils

MIT
Latest version published 2 months ago

Package Health Score

83 / 100
Full package analysis