How to use the node-opcua-nodeid.NodeIdType.BYTESTRING 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
nodeIdType = NodeIdType.NUMERIC;
            break;
        case EnumNodeIdEncoding.Numeric:
            namespace = stream.readUInt16();
            value = stream.readUInt32();
            nodeIdType = NodeIdType.NUMERIC;
            break;
        case EnumNodeIdEncoding.String:
            namespace = stream.readUInt16();
            value = decodeString(stream);
            nodeIdType = NodeIdType.STRING;
            break;
        case EnumNodeIdEncoding.ByteString:
            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;
    }
github node-opcua / node-opcua / packages / node-opcua-server / src / server_session.js View on Github external
function ServerSession(parent, sessionTimeout) {

    const session = this;

    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);
github node-opcua / node-opcua / packages / node-opcua-server / source / server_session.ts View on Github external
constructor(parent: any, sessionTimeout: number) {

        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);
github node-opcua / node-opcua / packages / node-opcua-server / src / server_engine.js View on Github external
ServerEngine.prototype.getSession = function (authenticationToken, activeOnly) {

    const engine = this;
    if (!authenticationToken || (authenticationToken.identifierType && (authenticationToken.identifierType.value !== NodeIdType.BYTESTRING.value))) {
        return null;     // wrong type !
    }
    const key = authenticationToken.toString();
    let session = engine._sessions[key];
    if (!activeOnly && !session) {
        session = engine._closedSessions[key];
    }
    return session;
};
github node-opcua / node-opcua / packages / node-opcua-server / source / server_engine.ts View on Github external
public getSession(
    authenticationToken: NodeId,
    activeOnly?: boolean
  ): ServerSession | null {

    const engine = this;
    if (!authenticationToken ||
      (authenticationToken.identifierType &&
        (authenticationToken.identifierType !== NodeIdType.BYTESTRING))) {
      return null;     // wrong type !
    }
    const key = authenticationToken.toString();
    let session = engine._sessions[key];
    if (!activeOnly && !session) {
      session = engine._closedSessions[key];
    }
    return session;
  }
github node-opcua / node-opcua / packages / node-opcua-basic-types / source / nodeid.ts View on Github external
!(nodeId as ExpandedNodeId).namespaceUri &&
            !(nodeId as ExpandedNodeId).serverIndex) {
            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;
}