How to use the node-opcua-common.ServerState.get 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-client / src / client_session_keepalive_manager.js View on Github external
the_session.readVariableValue(serverStatus_State_Id, function (err, dataValue) {
        if (err) {
            console.log(" warning : ClientSessionKeepAliveManager#ping_server ".cyan, err.message.yellow);
            self.stop();

            /**
             * @event failure
             * raised when the server is not responding or is responding with en error to
             * the keep alive read Variable value transaction
             */
            self.emit("failure");

        } else {
            if (dataValue.statusCode === StatusCodes.Good) {
                const newState = ServerState.get(dataValue.value.value);
                //istanbul ignore next
                if (newState !== self.lastKnownState) {
                    console.log(" Server State = ", newState.toString());
                }
                self.lastKnownState = newState;
            }

            self.emit("keepalive",self.lastKnownState);
        }
        callback();
    });
};