How to use the node-opcua-common.ServerDiagnosticsSummary function in node-opcua-common

To help you get started, we’ve selected a few node-opcua-common 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-server / src / server_engine.js View on Github external
// --------------------------------------------------- ServerCapabilities
    options.serverCapabilities = options.serverCapabilities || {};
    options.serverCapabilities.serverProfileArray = options.serverCapabilities.serverProfileArray || [
        "Standard UA Server Profile",
        "Embedded UA Server Profile",
        "Micro Embedded Device Server Profile",
        "Nano Embedded Device Server Profile"
    ];
    options.serverCapabilities.localeIdArray = options.serverCapabilities.localeIdArray || ["en-EN", "fr-FR"];

    engine.serverCapabilities = new ServerCapabilities(options.serverCapabilities);
    engine.historyServerCapabilities = new HistoryServerCapabilities(options.historyServerCapabilities);

    // --------------------------------------------------- serverDiagnosticsSummary extension Object
    engine.serverDiagnosticsSummary = new ServerDiagnosticsSummary({});
    assert(engine.serverDiagnosticsSummary.hasOwnProperty("currentSessionCount"));

    // note spelling is different for serverDiagnosticsSummary.currentSubscriptionCount
    //      and sessionDiagnostics.currentSubscriptionsCount ( with an s)
    assert(engine.serverDiagnosticsSummary.hasOwnProperty("currentSubscriptionCount"));

    engine.serverDiagnosticsSummary.__defineGetter__("currentSubscriptionCount", function () {
        // currentSubscriptionCount returns the total number of subscriptions
        // that are currently active on all sessions
        let counter = 0;
        _.values(engine._sessions).forEach(function (session) {
            counter += session.currentSubscriptionCount;
        });
        return counter;
    });