Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'node-opcua-object-registry' 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.
const description = "Sender Certificate Error";
console.log(chalk.cyan(description), chalk.bgRed.yellow(statusCode!.toString()));
// OPCUA specification v1.02 part 6 page 42 $6.7.4
// If an error occurs after the Server has verified Message security it shall return a ServiceFault instead
// of a OpenSecureChannel response. The ServiceFault Message is described in Part 4, 7.28.
return this._send_error(statusCode!, "", message, callback);
}
this._handle_OpenSecureChannelRequest(message, callback);
});
}
}
import { ObjectRegistry } from "node-opcua-object-registry";
import { NodeClass } from "../../../node-opcua-data-model/dist";
ServerSecureChannelLayer.registry = new ObjectRegistry({});
(ServerSecureChannelLayer as any).prototype.checkCertificateCallback =
callbackify((ServerSecureChannelLayer as any).prototype.checkCertificate);
subscription.timerId = null;
subscription._start_timer();
}
util.inherits(Subscription, EventEmitter);
Subscription.minimumPublishingInterval = 50; // fastest possible
Subscription.defaultPublishingInterval = 1000; // one second
Subscription.maximumPublishingInterval = 1000 * 60 * 60 * 24 * 15; // 15 days
assert(Subscription.maximumPublishingInterval < 2147483647, "maximumPublishingInterval cannot exceed (2**31-1) ms ");
const ObjectRegistry = require("node-opcua-object-registry").ObjectRegistry;
Subscription.registry = new ObjectRegistry();
Subscription.prototype.getSessionId = function () {
const subscription = this;
return subscription.sessionId;
};
Subscription.prototype.toString = function () {
const subscription = this;
let str = "Subscription:\n";
str += " subscriptionId " + subscription.id + "\n";
str += " sessionId " + subscription.getSessionId().toString() + "\n";
str += " publishingEnabled " + subscription.publishingEnabled + "\n";
str += " maxKeepAliveCount " + subscription.maxKeepAliveCount + "\n";
str += " publishingInterval " + subscription.publishingInterval + "\n";
self._node = null;
self._semantic_version = 0;
if (doDebug) {
debugLog("Monitoring ", options.itemToMonitor.toString());
}
self._on_node_disposed = null;
MonitoredItem.registry.register(self);
}
util.inherits(MonitoredItem, EventEmitter);
const ObjectRegistry = require("node-opcua-object-registry").ObjectRegistry;
MonitoredItem.registry = new ObjectRegistry();
MonitoredItem.minimumSamplingInterval = 50; // 50 ms as a minimum sampling interval
MonitoredItem.defaultSamplingInterval = 1500; // 1500 ms as a default sampling interval
MonitoredItem.maximumSamplingInterval = 1000 * 60 * 60; // 1 hour !
function _validate_parameters(monitoringParameters) {
//xx assert(options instanceof MonitoringParameters);
assert(monitoringParameters.hasOwnProperty("clientHandle"));
assert(monitoringParameters.hasOwnProperty("samplingInterval"));
assert(_.isFinite(monitoringParameters.clientHandle));
assert(_.isFinite(monitoringParameters.samplingInterval));
assert(_.isBoolean(monitoringParameters.discardOldest));
assert(_.isFinite(monitoringParameters.queueSize));
assert(monitoringParameters.queueSize >= 0);
}
engine.addressSpace = null;
engine._shutdownTask = [];
engine._applicationUri = options.applicationUri || "";
options.serverDiagnosticsEnabled = options.hasOwnProperty("serverDiagnosticsEnable")
? options.serverDiagnosticsEnabled : true;
engine.serverDiagnosticsEnabled = options.serverDiagnosticsEnabled;
}
util.inherits(ServerEngine, EventEmitter);
const ObjectRegistry = require("node-opcua-object-registry").ObjectRegistry;
ServerEngine.registry = new ObjectRegistry();
ServerEngine.prototype.dispose = function () {
const engine = this;
engine.addresSpaec = null;
assert(Object.keys(engine._sessions).length === 0, "ServerEngine#_sessions not empty");
engine._sessions = {};
// todo fix me
engine._closedSessions = {};
assert(Object.keys(engine._closedSessions).length === 0, "ServerEngine#_closedSessions not empty");
engine._closedSessions = {};
if (engine._orphanPublishEngine) {
engine._orphanPublishEngine.dispose();
// have expired but that still need to send some pending notification
// to the client.
// Once publish requests will be received from the client
// the notifications of those subscriptions will be processed so that
// they can be properly disposed.
self._closed_subscriptions = [];
self.maxPublishRequestInQueue = options.maxPublishRequestInQueue || 100;
self.isSessionClosed = false;
}
util.inherits(ServerSidePublishEngine, EventEmitter);
const ObjectRegistry = require("node-opcua-object-registry").ObjectRegistry;
ServerSidePublishEngine.registry = new ObjectRegistry();
ServerSidePublishEngine.prototype.dispose = function () {
debugLog("ServerSidePublishEngine#dispose");
const self = this;
// force deletion of publish response not sent
self._publish_response_queue = [];
assert(self._publish_response_queue.length === 0, "self._publish_response_queue !=0");
self._publish_response_queue = null;
assert(Object.keys(self._subscriptions).length === 0, "self._subscriptions count!=0");
self._subscriptions = {};
if (self.messageChunker) {
self.messageChunker.dispose();
self.messageChunker = null;
}
self.secureChannelId = 0xdeadbeef;
self.timeoutId = null;
self.sessionTokens = null;
self.removeAllListeners();
};
const ObjectRegistry = require("node-opcua-object-registry").ObjectRegistry;
ServerSecureChannelLayer.registry = new ObjectRegistry();
/**
* the endpoint associated with this secure channel
* @property endpoints
* @type {OPCUAServerEndPoint}
*
*/
ServerSecureChannelLayer.prototype.__defineGetter__("endpoints", function() {
return this.parent;
});
ServerSecureChannelLayer.prototype.setSecurity = function(securityMode, securityPolicy) {
const self = this;
// TODO verify that the endpoint really supports this mode
self.messageBuilder.setSecurity(securityMode, securityPolicy);
};
"use strict";
Error.stackTraceLimit = Infinity;
const assert = require("node-opcua-assert").assert;
const _ = require("underscore");
const chalk = require("chalk");
const ObjectRegistry = require("node-opcua-object-registry").ObjectRegistry;
ObjectRegistry.doDebug = true;
const trace = false;
//trace = true;
function get_stack() {
const stack = (new Error("Stack Trace recording")).stack.split("\n");
return stack.slice(2, 7).join("\n");
}
const monitor_intervals = false;
function ResourceLeakDetector() {
const self = this;
self.setIntervalCallCount = 0;
errorMessages.push(" setInterval doesn't match number of clearInterval calls : \n " +
" setIntervalCallCount = " + self.setIntervalCallCount +
" clearIntervalCallCount = " + self.clearIntervalCallCount);
}
if ((self.clearTimeoutCallCount + self.honoredTimeoutFuncCallCount) !== self.setTimeoutCallCount) {
errorMessages.push(" setTimeout doesn't match number of clearTimeout or achieved timer calls : \n " +
" setTimeoutCallCount = " + self.setTimeoutCallCount +
" clearTimeoutCallCount = " + self.clearTimeoutCallCount +
" honoredTimeoutFuncCallCount = " + self.honoredTimeoutFuncCallCount);
}
if (self.setTimeoutCallPendingCount !== 0) {
errorMessages.push(" setTimeoutCallPendingCount is not zero: some timer are still pending " +
self.setTimeoutCallPendingCount);
}
const monitoredResource = ObjectRegistry.registries;
for (let i = 0; i < monitoredResource.length; i++) {
const res = monitoredResource[i];
if (res.count() !== 0) {
errorMessages.push(" some Resource have not been properly terminated: " + res.toString());
}
}
if (errorMessages.length) {
//xx if (info) {
//xx console.log(" TRACE : ", info);
//xx }
console.log(errorMessages.join("\n"));
console.log("----------------------------------------------- more info");
/***
* @property keepPendingSessionsOnDisconnect²
* @type {boolean}
*/
this.keepPendingSessionsOnDisconnect = options.keepPendingSessionsOnDisconnect || false;
}
util.inherits(OPCUAClientBase, EventEmitter);
OPCUAClientBase.prototype.getPrivateKey = OPCUASecureObject.prototype.getPrivateKey;
OPCUAClientBase.prototype.getCertificate = OPCUASecureObject.prototype.getCertificate;
OPCUAClientBase.prototype.getCertificateChain = OPCUASecureObject.prototype.getCertificateChain;
const ObjectRegistry = require("node-opcua-object-registry").ObjectRegistry;
OPCUAClientBase.registry = new ObjectRegistry();
/**
* is true when the client has already requested the server end points.
* @property knowsServerEndpoint
* @type boolean
*/
OPCUAClientBase.prototype.__defineGetter__("knowsServerEndpoint", function () {
const self = this;
return (self._server_endpoints && self._server_endpoints.length > 0);
});
OPCUAClientBase.prototype._destroy_secure_channel = function () {
const self = this;
if (self._secureChannel) {
if (!_.isFunction(self.userManager.isValidUser)) {
self.userManager.isValidUser = function (/*userName,password*/) {
return false;
};
}
self.discoveryServerEndpointUrl = options.discoveryServerEndpointUrl || "opc.tcp://localhost:4840";
assert(typeof self.discoveryServerEndpointUrl === "string");
self.capabilitiesForMDNS = options.capabilitiesForMDNS || [ "NA" ];
self.registerServerMethod = options.registerServerMethod || RegisterServerMethod.HIDDEN;
_installRegisterServerManager(self);
}
util.inherits(OPCUAServer, OPCUABaseServer);
const ObjectRegistry = require("node-opcua-object-registry").ObjectRegistry;
OPCUAServer.registry = new ObjectRegistry();
/**
* total number of bytes written by the server since startup
* @property bytesWritten
* @type {Number}
*/
OPCUAServer.prototype.__defineGetter__("bytesWritten", function () {
return this.endpoints.reduce(function (accumulated, endpoint) {
return accumulated + endpoint.bytesWritten;
}, 0);
});
/**
* total number of bytes read by the server since startup
* @property bytesRead