How to use the node-opcua-common.ServerState.Shutdown 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 / source / server_engine.ts View on Github external
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");
github node-opcua / node-opcua / packages / node-opcua-server / src / server_engine.js View on Github external
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) {
github node-opcua / node-opcua / packages / node-opcua-server / src / opcua_server.js View on Github external
if (!callback) {
        callback = timeout;
        timeout = 10; // 1 second
    }
    assert(_.isFunction(callback));
    const self = this;

    debugLog("OPCUAServer#shutdown (timeout = ", timeout, ")");

    assert(self.engine);
    if (!self.engine.serverStatus) {
        // server may have been shot down already  , or may have fail to start !!
        const err = new Error("OPCUAServer#shutdown failure ! server doesn't seems to be started yet");
        return callback(err);
    }
    self.engine.setServerState(ServerState.Shutdown);

    self.registerServerManager.stop(function (err) {
        debugLog("OPCUServer unregistered from discovery server",err);
        setTimeout(function () {
            self.engine.shutdown();

            debugLog("OPCUAServer#shutdown: started");
            OPCUABaseServer.prototype.shutdown.call(self, function (err) {
                debugLog("OPCUAServer#shutdown: completed");

                self.dispose();
                callback(err);
            });
        }, timeout);
    });