Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
});
ServerSession.prototype.__defineGetter__("addressSpace", function () {
return this.parent ? this.parent.addressSpace : null;
});
ServerSession.prototype.__defineGetter__("currentPublishRequestInQueue", function () {
const self = this;
return self.publishEngine ? self.publishEngine.pendingPublishRequestCount : 0;
});
//xx ServerSession.prototype.__defineGetter__("serverDiagnostics")
const ServiceCounterDataType = require("node-opcua-common").ServiceCounterDataType;
const SessionDiagnosticsDataType = require("node-opcua-common").SessionDiagnosticsDataType;
const SubscriptionDiagnosticsDataType = require("node-opcua-common").SubscriptionDiagnosticsDataType;
ServerSession.prototype.updateClientLastContactTime = function (currentTime) {
const session = this;
if (session._sessionDiagnostics && session._sessionDiagnostics.clientLastContactTime) {
currentTime = currentTime || new Date();
// do not record all ticks as this may be overwhelming,
if (currentTime.getTime() - 250 >= session._sessionDiagnostics.clientLastContactTime.getTime()) {
session._sessionDiagnostics.clientLastContactTime = currentTime;
}
}
};
/**
const SubscriptionState = new Enum([
"CLOSED", // The Subscription has not yet been created or has terminated.
"CREATING", // The Subscription is being created
"NORMAL", // The Subscription is cyclically checking for Notifications from its MonitoredItems.
// The keep-alive counter is not used in this state.
"LATE", // The publishing timer has expired and there are Notifications available or a keep-alive Message is
// ready to be sent, but there are no Publish requests queued. When in this state, the next Publish
// request is processed when it is received. The keep-alive counter is not used in this state.
"KEEPALIVE",// The Subscription is cyclically checking for Notification
// alive counter to count down to 0 from its maximum.
"TERMINATED"
]);
exports.SubscriptionState = SubscriptionState;
const SessionDiagnosticsDataType = require("node-opcua-common").SessionDiagnosticsDataType;
function _adjust_publishing_interval(publishingInterval) {
publishingInterval = publishingInterval || Subscription.defaultPublishingInterval;
publishingInterval = Math.max(publishingInterval, Subscription.minimumPublishingInterval);
publishingInterval = Math.min(publishingInterval, Subscription.maximumPublishingInterval);
return publishingInterval;
}
const minimumMaxKeepAliveCount = 2;
const maximumMaxKeepAliveCount = 12000;
function _adjust_maxKeepAliveCount(maxKeepAliveCount/*,publishingInterval*/) {
maxKeepAliveCount = maxKeepAliveCount || minimumMaxKeepAliveCount;
maxKeepAliveCount = Math.max(maxKeepAliveCount, minimumMaxKeepAliveCount);
maxKeepAliveCount = Math.min(maxKeepAliveCount, maximumMaxKeepAliveCount);