Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
encodingByte &= 0x3f; // 1 to 5
switch (encodingByte) {
case EnumNodeIdEncoding.TwoBytes:
value = stream.readUInt8();
nodeIdType = NodeIdType.NUMERIC;
break;
case EnumNodeIdEncoding.FourBytes:
namespace = stream.readUInt8();
value = stream.readUInt16();
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),
ServerSession.prototype.registerNode = function(nodeId) {
assert(nodeId instanceof NodeId);
const session = this;
if (nodeId.namespace === 0 && nodeId.identifierType === NodeIdType.NUMERIC) {
return nodeId;
}
const key = nodeId.toString();
const registeredNode = session._registeredNodes[key];
if (registeredNode) {
// already registered
return registeredNode;
}
const node = session.addressSpace.findNode(nodeId);
if (!node) {
return nodeId;
}
public registerNode(nodeId: NodeId) {
assert(nodeId instanceof NodeId);
const session = this;
if (nodeId.namespace === 0 && nodeId.identifierType === NodeIdType.NUMERIC) {
return nodeId;
}
const key = nodeId.toString();
const registeredNode = session._registeredNodes[key];
if (registeredNode) {
// already registered
return registeredNode;
}
const node = session.addressSpace.findNode(nodeId);
if (!node) {
return nodeId;
}
function nodeID_encodingByte(nodeId: NodeId): number {
if (!nodeId) {
return 0;
}
assert(nodeId.hasOwnProperty("identifierType"));
let encodingByte = 0;
if (nodeId.identifierType === NodeIdType.NUMERIC) {
if (isUInt8(nodeId.value as number) &&
!nodeId.namespace &&
!(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) {