Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'node-opcua-common' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
public shutdown() {
debugLog("ServerEngine#shutdown");
this.status = "shutdown";
this.setServerState(ServerState.Shutdown);
// delete any existing sessions
const tokens = Object.keys(this._sessions).map((key: string) => {
const session = this._sessions[key];
return session.authenticationToken;
});
// delete and close any orphan subscriptions
if (this._orphanPublishEngine) {
this._orphanPublishEngine.shutdown();
}
// xx console.log("xxxxxxxxx ServerEngine.shutdown must terminate "+ tokens.length," sessions");
tokens.forEach((token: any) => {
this.closeSession(token, true, "Terminated");
ServerEngine.prototype.shutdown = function () {
debugLog("ServerEngine#shutdown");
const engine = this;
engine.status = "shutdown";
engine.setServerState(ServerState.Shutdown);
// delete any existing sessions
const tokens = Object.keys(engine._sessions).map(function (key) {
const session = engine._sessions[key];
return session.authenticationToken;
});
// delete and close any orphan subscription
if (engine._orphanPublishEngine) {
engine._orphanPublishEngine.shutdown();
}
//xx console.log("xxxxxxxxx ServerEngine.shutdown must terminate "+ tokens.length," sessions");
tokens.forEach(function (token) {
// get applicationURI from certificate
const exploreCertificate = require("node-opcua-crypto").exploreCertificate;
const certificate = this.getCertificate();
let applicationUri;
if (certificate) {
const e = exploreCertificate(certificate);
if (!e.tbsCertificate.extensions || !e.tbsCertificate.extensions.subjectAltName) {
console.log(chalk.red(" Warning: client certificate is invalid : subjectAltName is missing"));
applicationUri = makeApplicationUrn(hostname, this.applicationName);
} else {
applicationUri = e.tbsCertificate.extensions.subjectAltName.uniformResourceIdentifier[0];
}
} else {
applicationUri = makeApplicationUrn(hostname, this.applicationName);
}
return applicationUri;
};
init(this: any) {
this.enumValueType = new EnumValueType({
description: undefined,
displayName: undefined,
value: [0, 0] // Int64
});
},
parser: {
endPoint.on("error", function (err) {
console.log("OPCUAServer endpoint error", err);
// set serverState to ServerState.Failed;
self.engine.setServerState(ServerState.Failed);
self.shutdown(function () {
});
});
addressSpace.modelChangeTransaction(() => {
// ...
for (const r of references) {
const target = addressSpace.findNode(r.nodeId)!;
const modelChangeSrc_l = new ModelChangeStructureDataType({
affected: target.nodeId,
affectedType: null,
verb: makeVerb("ReferenceDeleted")
});
addressSpace._collectModelChange(null, modelChangeSrc_l);
}
const modelChangeSrc = new ModelChangeStructureDataType({
affected: node.nodeId,
affectedType: node.typeDefinition,
verb: makeVerb("NodeDeleted")
});
addressSpace._collectModelChange(null, modelChangeSrc);
});
affected: node.nodeId,
affectedType: typeDefinitionNodeId,
verb: makeVerb("NodeAdded")
});
addressSpace._collectModelChange(null, modelChange1);
const modelChangeSrc = new ModelChangeStructureDataType({
affected: parent.nodeId,
affectedType: null,
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeSrc);
// bidirectional
if (node.nodeVersion) {
const modelChangeTgt = new ModelChangeStructureDataType({
affected: node.nodeId,
affectedType: typeDefinitionNodeId,
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeTgt);
}
});
}
addressSpace.modelChangeTransaction(() => {
let typeDefinitionNodeId = null;
if (node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable) {
typeDefinitionNodeId = node.typeDefinitionObj.nodeId;
}
const modelChange1 = new ModelChangeStructureDataType({
affected: node.nodeId,
affectedType: typeDefinitionNodeId,
verb: makeVerb("NodeAdded")
});
addressSpace._collectModelChange(null, modelChange1);
const modelChangeSrc = new ModelChangeStructureDataType({
affected: parent.nodeId,
affectedType: null,
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeSrc);
// bidirectional
if (node.nodeVersion) {
const modelChangeTgt = new ModelChangeStructureDataType({
affected: node.nodeId,
affectedType: typeDefinitionNodeId,
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeTgt);
}
});
addressSpace.modelChangeTransaction(() => {
let typeDefinitionNodeId = null;
if (node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable) {
typeDefinitionNodeId = node.typeDefinitionObj.nodeId;
}
const modelChange1 = new ModelChangeStructureDataType({
affected: node.nodeId,
affectedType: typeDefinitionNodeId,
verb: makeVerb("NodeAdded")
});
addressSpace._collectModelChange(null, modelChange1);
const modelChangeSrc = new ModelChangeStructureDataType({
affected: parent.nodeId,
affectedType: null,
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeSrc);
// bidirectional
if (node.nodeVersion) {
const modelChangeTgt = new ModelChangeStructureDataType({
module.exports.UserIdentityTokenType = require("node-opcua-service-endpoints").UserIdentityTokenType;
module.exports.subscription_service = require("node-opcua-service-subscription");
module.exports.historizing_service = require("node-opcua-service-history");
module.exports.discovery_service = require("node-opcua-service-discovery");
module.exports.secure_channel_service = require("node-opcua-service-secure-channel");
module.exports.translate_browse_paths_to_node_ids_service = require("node-opcua-service-translate-browse-path");
module.exports.BrowsePath = require("node-opcua-service-translate-browse-path").BrowsePath;
module.exports.makeRelativePath = require("node-opcua-service-translate-browse-path").makeRelativePath;
module.exports.makeBrowsePath = require("node-opcua-service-translate-browse-path").makeBrowsePath;
module.exports.query_service = require("node-opcua-service-query");
module.exports.node_managment_service = require("node-opcua-service-node-management");
module.exports.ServerState = require("node-opcua-common").ServerState;
module.exports.ServiceCounter = require("node-opcua-common").ServiceCounter;
module.exports.SecurityPolicy = require("node-opcua-secure-channel").SecurityPolicy;
module.exports.MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
module.exports.utils = require("node-opcua-utils");
module.exports.crypto_utils = require("node-opcua-crypto");
module.exports.hexDump = require("node-opcua-debug").hexDump;
//----------------------------------------------------------------------------------------------------------------------
// client services
//----------------------------------------------------------------------------------------------------------------------
module.exports.OPCUAClient = require("node-opcua-client").OPCUAClient;
module.exports.OPCUAClientBase = require("node-opcua-client").OPCUAClientBase;
module.exports.NodeCrawler = require("node-opcua-client-crawler").NodeCrawler;