How to use the node-opcua-status-code.StatusCodes.BadNothingToDo function in node-opcua-status-code

To help you get started, we’ve selected a few node-opcua-status-code 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
}
    if (!subscription.$session) {
      return new TransferResult({ statusCode: StatusCodes.BadInternalError });
    }

    // update diagnostics 
    subscription.subscriptionDiagnostics.transferRequestCount++;

    // now check that new session has sufficient right
    // if (session.authenticationToken.toString() !== subscription.authenticationToken.toString()) {
    //     console.log("ServerEngine#transferSubscription => BadUserAccessDenied");
    //     return new TransferResult({ statusCode: StatusCodes.BadUserAccessDenied });
    // }
    if (session.publishEngine === subscription.publishEngine) {
      // subscription is already in this session !!
      return new TransferResult({ statusCode: StatusCodes.BadNothingToDo });
    }
    if (session === subscription.$session) {
      // subscription is already in this session !!
      return new TransferResult({ statusCode: StatusCodes.BadNothingToDo });
    }

    // The number of times the subscription has been transferred to an alternate client.
    subscription.subscriptionDiagnostics.transferredToAltClientCount++;
    // The number of times the subscription has been transferred to an alternate session for the same client.
    subscription.subscriptionDiagnostics.transferredToSameClientCount++;

    const nbSubscriptionBefore = session.publishEngine.subscriptionCount;

    subscription.$session._unexposeSubscriptionDiagnostics(subscription);
    ServerSidePublishEngine.transferSubscription(subscription, session.publishEngine, sendInitialValues);
github node-opcua / node-opcua / packages / node-opcua-server / src / server_engine.js View on Github external
const subscription = engine.findSubscription(subscriptionId);
    if (!subscription) {
        return new TransferResult({statusCode: StatusCodes.BadSubscriptionIdInvalid});
    }
    // // now check that new session has sufficient right
    // if (session.authenticationToken.toString() !== subscription.authenticationToken.toString()) {
    //     console.log("ServerEngine#transferSubscription => BadUserAccessDenied");
    //     return new TransferResult({ statusCode: StatusCodes.BadUserAccessDenied });
    // }
    if (session.publishEngine === subscription.publishEngine) {
        // subscription is already in this session !!
        return new TransferResult({statusCode: StatusCodes.BadNothingToDo});
    }
    if (session === subscription.$session) {
        // subscription is already in this session !!
        return new TransferResult({statusCode: StatusCodes.BadNothingToDo});
    }

    const nbSubscriptionBefore = session.publishEngine.subscriptionCount;

    subscription.$session._unexposeSubscriptionDiagnostics(subscription);
    ServerSidePublishEngine.transferSubscription(subscription, session.publishEngine, sendInitialValues);
    subscription.$session = session;

    session._exposeSubscriptionDiagnostics(subscription);

    assert(subscription.publishEngine === session.publishEngine);
    assert(session.publishEngine.subscriptionCount === nbSubscriptionBefore + 1);

    // TODO: If the Server transfers the Subscription to the new Session, the Server shall issue a
    //       StatusChangeNotification notificationMessage with the status code Good_SubscriptionTransferred
    //       to the old Session.
github node-opcua / node-opcua / packages / node-opcua-server / src / opcua_server.js View on Github external
if (request.view && !request.view.viewId.isEmpty()) {
            //xx console.log("xxxx ",request.view.toString());
            //xx console.log("xxxx NodeClas",View.prototype.nodeClass);
            let theView = server.engine.addressSpace.findNode(request.view.viewId);
            if (theView && theView.constructor.nodeClass !== View.prototype.nodeClass) {
                // Error: theView is not a View
                diagnostic.localizedText = {text: "blah"};
                theView = null;
            }
            if (!theView) {
                return sendError(StatusCodes.BadViewIdUnknown, diagnostic);
            }
        }

        if (!request.nodesToBrowse || request.nodesToBrowse.length === 0) {
            return sendError(StatusCodes.BadNothingToDo);
        }

        if (server.engine.serverCapabilities.operationLimits.maxNodesPerBrowse > 0) {
            if (request.nodesToBrowse.length > server.engine.serverCapabilities.operationLimits.maxNodesPerBrowse) {
                return sendError(StatusCodes.BadTooManyOperations);
            }
        }

        // ToDo: limit results to requestedMaxReferencesPerNode
        const requestedMaxReferencesPerNode = request.requestedMaxReferencesPerNode;

        let results = [];
        assert(request.nodesToBrowse[0]._schema.name === "BrowseDescription");
        results = server.engine.browse(request.nodesToBrowse, session);
        assert(results[0]._schema.name === "BrowseResult");
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space_browse.js View on Github external
AddressSpace.prototype.browsePath = function (browsePath) {

        const self = this;

        assert(browsePath instanceof translate_service.BrowsePath);

        const startingNode = self.findNode(browsePath.startingNode);

        if (!startingNode) {
            return new BrowsePathResult({statusCode: StatusCodes.BadNodeIdUnknown});
        }

        if (!browsePath.relativePath.elements || browsePath.relativePath.elements.length === 0) {
            return new BrowsePathResult({
                statusCode: StatusCodes.BadNothingToDo,
                targets: []
            });
        }


        const elements_length = browsePath.relativePath.elements.length;
        //-------------------------------------------------------------------------------------------------------
        // verify standard RelativePath construction
        //   from OPCUA 1.03 - PArt 3 - 7.6 RelativePath:
        //   TargetName  The BrowseName of the target node.
        //               The final element may have an empty targetName. In this situation all targets of the
        //               references identified by the referenceTypeId are the targets of the RelativePath.
        //               The targetName shall be specified for all other elements.
        //               The current path cannot be followed any further if no targets with the specified
        //               BrowseName exist.
        //   Let's detect null targetName which are not in last position and return Bad_BrowseNameInvalid if not
github node-opcua / node-opcua / packages / node-opcua-address-space / src / address_space.ts View on Github external
public browsePath(browsePath: BrowsePath): BrowsePathResult {

        assert(browsePath instanceof BrowsePath);

        const startingNode = this.findNode(browsePath.startingNode);

        if (!startingNode) {
            return new BrowsePathResult({ statusCode: StatusCodes.BadNodeIdUnknown });
        }

        if (!browsePath.relativePath.elements || browsePath.relativePath.elements.length === 0) {
            return new BrowsePathResult({
                statusCode: StatusCodes.BadNothingToDo,
                targets: []
            });
        }

        const elements_length = browsePath.relativePath.elements.length;
        // -------------------------------------------------------------------------------------------------------
        // verify standard RelativePath construction
        //   from OPCUA 1.03 - PArt 3 - 7.6 RelativePath:
        //   TargetName  The BrowseName of the target node.
        //               The final element may have an empty targetName. In this situation all targets of the
        //               references identified by the referenceTypeId are the targets of the RelativePath.
        //               The targetName shall be specified for all other elements.
        //               The current path cannot be followed any further if no targets with the specified
        //               BrowseName exist.
        //   Let's detect null targetName which are not in last position and return BadBrowseNameInvalid if not
        //
github node-opcua / node-opcua / packages / node-opcua-server / src / opcua_server.js View on Github external
this._apply_on_SessionObject(UnregisterNodesResponse, message, channel, function (session, sendResponse, sendError) {

        let response;

        if (!request.nodesToUnregister || request.nodesToUnregister.length === 0) {
            response = new UnregisterNodesResponse({responseHeader: {serviceResult: StatusCodes.BadNothingToDo}});
            return sendResponse(response);
        }
        if (server.engine.serverCapabilities.operationLimits.maxNodesPerRegisterNodes > 0) {
            if (request.nodesToUnregister.length > server.engine.serverCapabilities.operationLimits.maxNodesPerRegisterNodes) {
                return sendError(StatusCodes.BadTooManyOperations);
            }
        }

        request.nodesToUnregister.map(nodeId => session.unRegisterNode(nodeId));

        response = new UnregisterNodesResponse({});
        sendResponse(response);
    });