当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript thenify.withCallback函数代码示例

本文整理汇总了TypeScript中thenify.withCallback函数的典型用法代码示例。如果您正苦于以下问题:TypeScript withCallback函数的具体用法?TypeScript withCallback怎么用?TypeScript withCallback使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了withCallback函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: require

                            }
                        }
                    });
                });
            }
        });

        secureChannel.on("timed_out_request", (request: Request) => {
            /**
             * send when a request has timed out without receiving a response
             * @event timed_out_request
             * @param request
             */
            this.emit("timed_out_request", request);
        });
    }
}

// tslint:disable:no-var-requires
// tslint:disable:max-line-length
const thenify = require("thenify");
ClientBaseImpl.prototype.connect = thenify.withCallback(ClientBaseImpl.prototype.connect);
ClientBaseImpl.prototype.disconnect = thenify.withCallback(ClientBaseImpl.prototype.disconnect);
ClientBaseImpl.prototype.getEndpoints = thenify.withCallback(ClientBaseImpl.prototype.getEndpoints);
ClientBaseImpl.prototype.findServers = thenify.withCallback(ClientBaseImpl.prototype.findServers);
ClientBaseImpl.prototype.findServersOnNetwork = thenify.withCallback(ClientBaseImpl.prototype.findServersOnNetwork);

OPCUAClientBase.create = (options: OPCUAClientBaseOptions): OPCUAClientBase => {
    return new ClientBaseImpl(options);
};
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:client_base_impl.ts

示例2: translateBrowsePath

    public translateBrowsePath(browsePaths: BrowsePath[], callback: ResponseCallback<BrowsePathResult[]>): void;
    public translateBrowsePath(browsePath: BrowsePath, callback: ResponseCallback<BrowsePathResult>): void;
    public translateBrowsePath(browsePath: BrowsePath): Promise<BrowsePathResult>;
    public translateBrowsePath(browsePaths: BrowsePath[]): Promise<BrowsePathResult[]>;
    public translateBrowsePath(
      browsePaths: BrowsePath[] | BrowsePath,
      callback?: any
    ): any {

        const isArray = _.isArray(browsePaths);
        if (!isArray) {
            browsePaths = [browsePaths as BrowsePath];
        }
        // xx const context = new SessionContext({ session: null });
        const browsePathResults = (browsePaths as BrowsePath[]).map((browsePath: BrowsePath) => {
            return this.addressSpace.browsePath(browsePath);
        });
        callback!(null, isArray ? browsePathResults : browsePathResults[0]);
    }
}

// tslint:disable:no-var-requires
// tslint:disable:max-line-length
const thenify = require("thenify");
PseudoSession.prototype.read = thenify.withCallback(PseudoSession.prototype.read);
PseudoSession.prototype.browse = thenify.withCallback(PseudoSession.prototype.browse);
PseudoSession.prototype.browseNext = thenify.withCallback(PseudoSession.prototype.browseNext);
PseudoSession.prototype.getArgumentDefinition = thenify.withCallback(PseudoSession.prototype.getArgumentDefinition);
PseudoSession.prototype.call = thenify.withCallback(PseudoSession.prototype.call);
PseudoSession.prototype.translateBrowsePath = thenify.withCallback(PseudoSession.prototype.translateBrowsePath);
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:pseudo_session.ts

示例3: done

                    this.emit("terminated");
                }
                if (done) {
                    done(err);
                }
            });
    }

}

// tslint:disable:no-var-requires
// tslint:disable:max-line-length
const thenify = require("thenify");
const opts = {multiArgs: false};

ClientMonitoredItemImpl.prototype.terminate = thenify.withCallback(ClientMonitoredItemImpl.prototype.terminate);
ClientMonitoredItemImpl.prototype.setMonitoringMode = thenify.withCallback(ClientMonitoredItemImpl.prototype.setMonitoringMode);
ClientMonitoredItemImpl.prototype.modify = thenify.withCallback(ClientMonitoredItemImpl.prototype.modify);

ClientMonitoredItem.create = (
    subscription: ClientSubscription,
    itemToMonitor: ReadValueIdOptions,
    monitoringParameters: MonitoringParametersOptions,
    timestampsToReturn: TimestampsToReturn
) => {
    const monitoredItem = new ClientMonitoredItemImpl(
        subscription,
        itemToMonitor,
        monitoringParameters,
        timestampsToReturn
    );
开发者ID:node-opcua,项目名称:node-opcua,代码行数:31,代码来源:client_monitored_item_impl.ts

示例4: getStateMachineType

    }

    public getStateMachineType(
        nodeId: NodeIdLike,
        callback: (err: Error | null, stateMachineType?: ProxyStateMachineType) => void
    ) {

        if (typeof nodeId === "string") {
            const org_nodeId = nodeId;
            nodeId = makeRefId(nodeId);
        }

        this.getObject(nodeId, (err: Error | null, obj: any) => {

            // read fromState and toState Reference on
            let stateMachineType;
            if (!err) {
                stateMachineType = new ProxyStateMachineType(obj);
            }
            callback(err, stateMachineType);
        });

    }
}

// tslint:disable-next-line:no-var-requires
const thenify = require("thenify");
UAProxyManager.prototype.start = thenify.withCallback(UAProxyManager.prototype.start);
UAProxyManager.prototype.stop = thenify.withCallback(UAProxyManager.prototype.stop);
UAProxyManager.prototype.getObject = thenify.withCallback(UAProxyManager.prototype.getObject);
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:proxy_manager.ts

示例5: coerceNodeId

                        : NodeId.nullNodeId);

            const nodesToRead: ReadValueIdOptions [] = nodeIds.map((nodeId: NodeId) => ({
                    attributeId: AttributeIds.Value,
                    nodeId/*: coerceNodeId(nodeId)*/}));

            const data: HistoryServerCapabilities = {};

            session.read(nodesToRead, (err2: Error | null, dataValues?: DataValue[]) => {

                if (err2) {
                    return callback(err2);
                }
                if (!dataValues) {
                    return callback(new Error("Internal Error"));
                }

                for (let i = 0; i < dataValues.length; i++) {
                    const propName = lowerFirstLetter(properties[i]);
                    data[propName] = dataValues[i].value as Variant;
                }
                callback(null, data);
            });
        });
    });
}
// tslint:disable:no-var-requires
const thenify = require("thenify");
const opts = {multiArgs: false};
(module as any).exports.readHistoryServerCapabilities = thenify.withCallback((module as any).exports.readHistoryServerCapabilities, opts);
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:read_history_server_capabilities.ts

示例6: callback

        };
        this.proxyManager.session.write(nodeToWrite, (err: Error|null, statusCode?: StatusCode) => {
            // istanbul ignore next
            if (err) {
                return callback(err);
            }
            if (statusCode !== StatusCodes.Good) {
                callback(new Error(statusCode!.toString()));
            } else {
                callback();
            }
        });
    }

    public toString() {

        const str = [];
        str.push(" ProxyObject ");
        str.push("   browseName     : " + this.browseName.toString());
        // str.push("   typeDefinition : " + this.typeDefinition.toString());
        str.push("   $components#   : " + this.$components.length.toString());
        str.push("   $properties#   : " + this.$properties.length.toString());

        return str.join("\n");
    }
}
// tslint:disable:no-var-requires
const thenify = require("thenify");
ProxyBaseNode.prototype.readValue = thenify.withCallback(ProxyBaseNode.prototype.readValue);
ProxyBaseNode.prototype.writeValue = thenify.withCallback(ProxyBaseNode.prototype.writeValue);
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:proxy_base_node.ts

示例7: callback

                    return callback(new Error("CLIENT: Invalid userIdentityInfo"));
            }
        } catch (err) {
            if (typeof err === "string") {
                return callback(new Error("Create identity token failed " + userIdentityInfo.type + " " + err));
            }
            return callback(err);
        }
        return callback(null, { userIdentityToken, userTokenSignature });
    }
}

// tslint:disable:no-var-requires
// tslint:disable:max-line-length
const thenify = require("thenify");
OPCUAClientImpl.prototype.connect = thenify.withCallback(OPCUAClientImpl.prototype.connect);
OPCUAClientImpl.prototype.disconnect = thenify.withCallback(OPCUAClientImpl.prototype.disconnect);
/**
 * @method createSession
 * @async
 *
 * @example
 *     // create a anonymous session
 *     const session = await client.createSession();
 *
 * @example
 *     // create a session with a userName and password
 *     const userIdentityInfo  = {UserTokenType.UserName, userName: "JoeDoe", password:"secret"};
 *     const session = client.createSession(userIdentityInfo);
 *
 */
开发者ID:node-opcua,项目名称:node-opcua,代码行数:31,代码来源:opcua_client_impl.ts

示例8: require

    ): any {
        this.isCertificateTrusted(certificate, (err: Error | null, trustedStatus?: string) => {
            callback!(err,
              err ? undefined : StatusCodes[trustedStatus!]);
        });
    }

}

// tslint:disable:no-var-requires
// tslint:disable:max-line-length
const thenify = require("thenify");
const opts = { multiArgs: false };

OPCUACertificateManager.prototype.checkCertificate =
  thenify.withCallback(OPCUACertificateManager.prototype.checkCertificate, opts);
OPCUACertificateManager.prototype.getTrustStatus =
  thenify.withCallback(OPCUACertificateManager.prototype.getTrustStatus, opts);

// also see OPCUA 1.02 part 4 :
//  - page 95  6.1.3 Determining if a Certificate is Trusted
// -  page 100 6.2.3 Validating a Software Certificate
//
export function checkCertificateValidity(certificate: Certificate): StatusCode {
    // Is the  signature on the SoftwareCertificate valid .?
    if (!certificate) {
        // missing certificate
        return StatusCodes.BadSecurityChecksFailed;
    }
    // Has SoftwareCertificate passed its issue date and has it not expired ?
    // check dates
开发者ID:node-opcua,项目名称:node-opcua,代码行数:31,代码来源:certificate_manager.ts

示例9: findServersOnNetwork

      callback: (err: Error | null, servers?: ServerOnNetwork[]) => void
): void;
export function findServersOnNetwork(
    discoveryServerEndpointUri: string,
    callback?: (err: Error | null, servers?: ServerOnNetwork[]) => void
): any {

    const client = new ClientBaseImpl({});

    client.connect(discoveryServerEndpointUri, (err?: Error) => {
        if (!err) {
            client.findServersOnNetwork((err1, servers) => {
                client.disconnect(() => {
                    callback!(err1, servers);
                });
            });
        } else {
            client.disconnect(() => {
                callback!(err);
            });
        }
    });
}

// tslint:disable:no-var-requires
const thenify = require("thenify");
(module.exports as any).findServersOnNetwork =
  thenify.withCallback((module.exports as any).findServersOnNetwork);
(module.exports as any).findServers =
  thenify.withCallback((module.exports as any).findServers);
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:findservers.ts

示例10: processProperty

        }

        processProperty(browsePathResults[0], "engineeringUnits");
        processProperty(browsePathResults[1], "engineeringUnitsRange");
        processProperty(browsePathResults[2], "instrumentRange");
        processProperty(browsePathResults[3], "valuePrecision");
        processProperty(browsePathResults[4], "definition");

        session.read(nodesToRead, (err1: Error | null, dataValues?: DataValue[]) => {
            if (err1) {
                return callback(err1);
            }
            if (!dataValues) {
                return callback(new Error("Internal Error"));
            }

            dataValues.forEach((result: DataValue, index: number) => {
                actions[index].call(null, result);
            });

            callback(err1, analogItemData);

        });
    });
}
// tslint:disable:no-var-requires
// tslint:disable:max-line-length
const thenify = require("thenify");
const opts = {multiArgs: false};
(module as any).exports.readUAAnalogItem = thenify.withCallback((module as any).exports.readUAAnalogItem, opts);
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:client_utils.ts


注:本文中的thenify.withCallback函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。