How to use the node-opcua-nodeid.NodeIdType.GUID function in node-opcua-nodeid

To help you get started, we’ve selected a few node-opcua-nodeid 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-basic-types / source / nodeid.ts View on Github external
namespace = stream.readUInt16();
            value = decodeByteString(stream);
            nodeIdType = NodeIdType.BYTESTRING;
            break;
        default:
            if (encodingByte !== EnumNodeIdEncoding.Guid) {
                /*jslint bitwise: true */
                // console.log(" encoding_byte = 0x" + encodingByte.toString(16),
                //     " bin=", ("0000000000000000" + encodingByte.toString(2)).substr(-16),
                //     encodingByte, encodingByte & 0x3f);

                throw new Error(" encoding_byte = " + encodingByte.toString(16));
            }
            namespace = stream.readUInt16();
            value = decodeGuid(stream);
            nodeIdType = NodeIdType.GUID;
            assert(isValidGuid(value));
            break;
    }
    return new NodeId(nodeIdType, value, namespace);
}
github node-opcua / node-opcua / packages / node-opcua-server / src / server_session.js View on Github external
session.parent = parent; // SessionEngine

    EventEmitter.apply(session, arguments);

    ServerSession.registry.register(session);

    assert(_.isFinite(sessionTimeout));
    assert(sessionTimeout >= 0, " sessionTimeout");
    session.sessionTimeout = sessionTimeout;

    const authenticationTokenBuf = crypto.randomBytes(16);
    session.authenticationToken = new NodeId(NodeIdType.BYTESTRING, authenticationTokenBuf);

    // the sessionId
    const ownNamespaceIndex = 1; // addressSpace.getOwnNamespace().index;
    session.nodeId = new NodeId(NodeIdType.GUID, ec.randomGuid(), ownNamespaceIndex);

    assert(session.authenticationToken instanceof NodeId);
    assert(session.nodeId instanceof NodeId);

    session._cumulatedSubscriptionCount = 0;

    session.publishEngine = new ServerSidePublishEngine({
        maxPublishRequestInQueue: ServerSession.maxPublishRequestInQueue
    });

    session.publishEngine.setMaxListeners(100);

    theWatchDog.addSubscriber(session, session.sessionTimeout);

    session.__status = "new";
github node-opcua / node-opcua / packages / node-opcua-server / source / server_session.ts View on Github external
super();

        this.parent = parent; // SessionEngine

        ServerSession.registry.register(this);

        assert(_.isFinite(sessionTimeout));
        assert(sessionTimeout >= 0, " sessionTimeout");
        this.sessionTimeout = sessionTimeout;

        const authenticationTokenBuf = crypto.randomBytes(16);
        this.authenticationToken = new NodeId(NodeIdType.BYTESTRING, authenticationTokenBuf);

        // the sessionId
        const ownNamespaceIndex = 1; // addressSpace.getOwnNamespace().index;
        this.nodeId = new NodeId(NodeIdType.GUID, randomGuid(), ownNamespaceIndex);

        assert(this.authenticationToken instanceof NodeId);
        assert(this.nodeId instanceof NodeId);

        this._cumulatedSubscriptionCount = 0;

        this.publishEngine = new ServerSidePublishEngine({
            maxPublishRequestInQueue: ServerSession.maxPublishRequestInQueue
        });

        this.publishEngine.setMaxListeners(100);

        theWatchDog.addSubscriber(this, this.sessionTimeout);

        this.__status = "new";
github node-opcua / node-opcua / packages / node-opcua-basic-types / source / nodeid.ts View on Github external
encodingByte = encodingByte | EnumNodeIdEncoding.TwoBytes;
        } else if (
            isUInt16(nodeId.value as number) &&
            isUInt8(nodeId.namespace) &&
            !(nodeId as ExpandedNodeId).namespaceUri &&
            !(nodeId as ExpandedNodeId).serverIndex
        ) {
            encodingByte = encodingByte | EnumNodeIdEncoding.FourBytes;
        } else {
            encodingByte = encodingByte | EnumNodeIdEncoding.Numeric;
        }
    } else if (nodeId.identifierType === NodeIdType.STRING) {
        encodingByte = encodingByte | EnumNodeIdEncoding.String;
    } else if (nodeId.identifierType === NodeIdType.BYTESTRING) {
        encodingByte = encodingByte | EnumNodeIdEncoding.ByteString;
    } else if (nodeId.identifierType === NodeIdType.GUID) {
        encodingByte = encodingByte | EnumNodeIdEncoding.Guid;
    }

    if (nodeId.hasOwnProperty("namespaceUri") && (nodeId as ExpandedNodeId).namespaceUri) {
        encodingByte = encodingByte | EnumNodeIdEncoding.NamespaceUriFlag;
    }
    if (nodeId.hasOwnProperty("serverIndex") && (nodeId as ExpandedNodeId).serverIndex) {
        encodingByte = encodingByte | EnumNodeIdEncoding.ServerIndexFlag;
    }
    return encodingByte;
}