Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "node-opcua-service-call in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'node-opcua-service-call' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

// xx console.log("xxx ",arg.toString());
            const propName = lowerFirstLetter(arg.name);

            const value = inputArgs[propName];
            if (value === undefined) {
                throw new Error("expecting input argument " + propName);
            }
            if (arrayType === VariantArrayType.Array) {
                if (!_.isArray(value)) {
                    throw new Error("expecting value to be an Array or a TypedArray");
                }
            }
            return new Variant({arrayType, dataType, value});
        });

        const methodToCall = new CallMethodRequest({
            inputArguments,
            methodId: reference.nodeId,
            objectId: obj.nodeId,
        });

        session.call(methodToCall, (err: Error | null, callResult?: CallMethodResult) => {

            // istanbul ignore next
            if (err) {
                return callback(err);
            }

            callResult = callResult!;

            if (callResult.statusCode !== StatusCodes.Good) {
                return callback(new Error("Error " + callResult.statusCode.toString()));
const propName = lowerFirstLetter(arg.name);

                const value = inputArgs[propName];
                if (value === undefined) {
                    throw new Error("expecting input argument " + propName);
                }
                if (arrayType === VariantArrayType.Array) {
                    if (!_.isArray(value)) {
                        throw new Error("expecting value to be an Array or a TypedArray");
                    }
                }

                return new Variant({arrayType: arrayType, dataType: dataType, value: value});
            });

            const methodToCall = new call_service.CallMethodRequest({
                objectId: obj.nodeId,
                methodId: reference.nodeId,
                inputArguments: inputArguments
            });

            //xx console.log(" calling ",methodToCall.toString());

            session.call(methodToCall, function (err, callResult) {

                // istanbul ignore next
                if (err) {
                    return callback(err);
                }
                if (callResult.statusCode !== StatusCodes.Good) {
                    return callback(new Error("Error " + callResult.statusCode.toString()));
                }
(innerCallback: ErrorCallback) => {

            const methodToCalls = [];

            methodToCalls.push(new CallMethodRequest({
                inputArguments: [
                    /* eventId */ new Variant({ dataType: "ByteString", value: eventId }),
                    /* comment */ new Variant({ dataType: "LocalizedText", value: comment })
                ],
                methodId,
                objectId: conditionId
            }));

            this.call(methodToCalls, (err: Error | null, results?: CallMethodResult[]) => {
                if (err) {
                    return innerCallback(err);
                }
                statusCode = results![0].statusCode;
                innerCallback();
            });
        }
ClientSession.prototype.getMonitoredItems = function (subscriptionId, callback) {

    // 
    // 
    // 
    const self = this;
    const methodsToCall =
        new call_service.CallMethodRequest({
            objectId: coerceNodeId("ns=0;i=2253"),  // ObjectId.Server
            methodId: coerceNodeId("ns=0;i=11492"), // MethodIds.Server_GetMonitoredItems;
            inputArguments: [
                // BaseDataType
                {dataType: DataType.UInt32, value: subscriptionId}
            ]
        });

    self.call([methodsToCall], function (err, result) {

            /* istanbul ignore next */
            if (err) {
                return callback(err);
            }

            result = result[0];
const subscription = session.getSubscription(subscriptionId);
    if (!subscription) {
        // subscription may belongs to a different session  that ours
        if (engine.findSubscription(subscriptionId)) {
            // if yes, then access to  Subscription data should be denied
            return callback(null, {statusCode: StatusCodes.BadUserAccessDenied});
        }

        return callback(null, {statusCode: StatusCodes.BadSubscriptionIdInvalid});
    }
    const result = subscription.getMonitoredItems();
    assert(result.statusCode);
    assert(_.isArray(result.serverHandles));
    assert(_.isArray(result.clientHandles));
    assert(result.serverHandles.length === result.clientHandles.length);
    const callMethodResult = new CallMethodResult({
        statusCode: result.statusCode,
        outputArguments: [
            {dataType: DataType.UInt32, arrayType: VariantArrayType.Array, value: result.serverHandles},
            {dataType: DataType.UInt32, arrayType: VariantArrayType.Array, value: result.clientHandles}
        ]
    });
    callback(null, callMethodResult);

}
const subscription = session.getSubscription(subscriptionId);
  if (!subscription) {
    // subscription may belongs to a different session  that ours
    if (engine.findSubscription(subscriptionId)) {
      // if yes, then access to  Subscription data should be denied
      return callback(null, { statusCode: StatusCodes.BadUserAccessDenied });
    }

    return callback(null, { statusCode: StatusCodes.BadSubscriptionIdInvalid });
  }
  const result = subscription.getMonitoredItems();
  assert(result.statusCode);
  assert(_.isArray(result.serverHandles));
  assert(_.isArray(result.clientHandles));
  assert(result.serverHandles.length === result.clientHandles.length);
  const callMethodResult = new CallMethodResult({
    statusCode: result.statusCode,

    outputArguments: [
      { dataType: DataType.UInt32, arrayType: VariantArrayType.Array, value: result.serverHandles },
      { dataType: DataType.UInt32, arrayType: VariantArrayType.Array, value: result.clientHandles }
    ]
  });
  callback(null, callMethodResult);

}
self.performMessageTransaction(request, function (err, response) {

        /* istanbul ignore next */
        if (err) {
            return callback(err);
        }
        assert(response instanceof call_service.CallResponse);
        callback(null, isArray ? response.results : response.results[0]);

    });
ClientSession.prototype.call = function (methodsToCall, callback) {

    const self = this;

    const isArray = _.isArray(methodsToCall);
    if (!isArray) { methodsToCall = [methodsToCall]; }

    assert(_.isArray(methodsToCall));

    // Note : The client has no explicit address space and therefore will struggle to
    //        access the method arguments signature.
    //        There are two methods that can be considered:
    //           - get the object definition by querying the server
    //           - load a fake address space to have some thing to query on our end
    // const request = self._client.factory.constructObjectId("CallRequest",{ methodsToCall: methodsToCall});
    const request = new call_service.CallRequest({methodsToCall: methodsToCall});

    self.performMessageTransaction(request, function (err, response) {

        /* istanbul ignore next */
        if (err) {
            return callback(err);
        }
        assert(response instanceof call_service.CallResponse);
        callback(null, isArray ? response.results : response.results[0]);

    });

};
value: options.inputArguments.map(function (opt) {
                    return new Argument(opt);
                })
            });

Is your System Free of Underlying Vulnerabilities?
Find Out Now