本文整理汇总了TypeScript中util.callbackify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript callbackify函数的具体用法?TypeScript callbackify怎么用?TypeScript callbackify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了callbackify函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: installPushCertificateManagement
export function installPushCertificateManagement(
addressSpace: AddressSpace,
options: PushCertificateManagerServerOptions
) {
const serverConfiguration = addressSpace.rootFolder.objects.server.serverConfiguration;
const serverConfigurationPriv = serverConfiguration as any;
if (serverConfigurationPriv.$pushCertificateManager) {
return;
throw new Error("PushCertificateManagement has already been installed");
}
serverConfigurationPriv.$pushCertificateManager = new PushCertificateManagerServerImpl(options);
serverConfiguration.supportedPrivateKeyFormats.setValueFromSource({
arrayType: VariantArrayType.Array,
dataType: DataType.String,
value: ["PEM"]
});
serverConfiguration.createSigningRequest.bindMethod(callbackify(_createSigningRequest));
serverConfiguration.updateCertificate.bindMethod(callbackify(_updateCertificate));
serverConfiguration.getRejectedList.bindMethod(callbackify(_getRejectedList));
if (serverConfiguration.applyChanges) {
serverConfiguration.applyChanges!.bindMethod(callbackify(_applyChanges));
}
installCertificateExpirationAlarm(addressSpace);
}
示例2: start
public start(done: (err?: Error) => void): void {
assert(!this.mDnsResponder);
assert(_.isArray(this.capabilitiesForMDNS));
callbackify(extractFullyQualifiedDomainName)((err1: Error | null, fqdn: string) => {
if (this._delayInit) {
this._delayInit();
this._delayInit = undefined;
}
super.start((err?: Error | null) => {
if (err) {
return done(err);
}
this.mDnsResponder = new MDNSResponder();
// declare discovery server in bonjour
this.bonjourHolder._announcedOnMulticastSubnetWithCallback({
capabilities: this.capabilitiesForMDNS,
name: this.serverInfo.applicationUri!,
path: "/DiscoveryServer",
port: this.endpoints[0].port
}, (err2: Error | null) => {
done(err2!);
});
});
});
}
示例3: make_back_references
}, (err?: Error | null) => {
make_back_references(addressSpace1);
// perform post task
debugLog("Performing post loading tasks");
async function performPostLoadingTasks(tasks: Task[]): Promise<void> {
for (const task of tasks) {
try {
await task(addressSpace1);
}
// istanbul ignore next
catch (err) {
console.log(" Err => ", err.message);
console.log(err);
}
}
}
callbackify(performPostLoadingTasks)(postTasks, () => {
postTasks = [];
debugLog("Post loading task done");
assert(!addressSpace1.suspendBackReference);
callback!(err || undefined);
});
});
示例4: __createSession_step2
/**
*
* @internal
* @private
*/
public __createSession_step2(
session: ClientSessionImpl,
callback: (err: Error | null, session?: ClientSessionImpl
) => void) {
callbackify(extractFullyQualifiedDomainName)(() => {
this.__createSession_step3(session, callback);
});
}
示例5: test
static test(): void {
const cfn = util.callbackify(callbackifyTest.fn);
const cfnE = util.callbackify(callbackifyTest.fnE);
const cfnT1 = util.callbackify(callbackifyTest.fnT1);
const cfnT1E = util.callbackify(callbackifyTest.fnT1E);
const cfnTResult = util.callbackify(callbackifyTest.fnTResult);
const cfnTResultE = util.callbackify(callbackifyTest.fnTResultE);
const cfnT1TResult = util.callbackify(callbackifyTest.fnT1TResult);
const cfnT1TResultE = util.callbackify(callbackifyTest.fnT1TResultE);
cfn((err: NodeJS.ErrnoException | null, ...args: string[]) => assert(err === null && args.length === 1 && args[0] === undefined));
cfnE((err: NodeJS.ErrnoException, ...args: string[]) => assert(err.message === 'fail' && args.length === 0));
cfnT1('parameter', (err: NodeJS.ErrnoException | null, ...args: string[]) => assert(err === null && args.length === 1 && args[0] === undefined));
cfnT1E('parameter', (err: NodeJS.ErrnoException, ...args: string[]) => assert(err.message === 'fail' && args.length === 0));
cfnTResult((err: NodeJS.ErrnoException | null, ...args: string[]) => assert(err === null && args.length === 1 && args[0] === 'result'));
cfnTResultE((err: NodeJS.ErrnoException, ...args: string[]) => assert(err.message === 'fail' && args.length === 0));
cfnT1TResult('parameter', (err: NodeJS.ErrnoException | null, ...args: string[]) => assert(err === null && args.length === 1 && args[0] === 'result'));
cfnT1TResultE('parameter', (err: NodeJS.ErrnoException, ...args: string[]) => assert(err.message === 'fail' && args.length === 0));
}
示例6: callback
if (this._service) {
// due to a wrong declaration of Service.stop in the d.ts file we
// need to use a workaround here
const this_service = this._service as any as ServiceFixed;
this._service = undefined;
this._multicastDNS = undefined;
this.announcement = undefined;
const proxy = (callback: (err?: Error) => void)=>{
this_service.stop(()=>{
callback();
})
};
const stop = promisify(proxy);
await stop.call(this);
releaseBonjour();
debugLog("stop announcement completed");
}
}
public _stop_announcedOnMulticastSubnetWithCallback(
callback: (err: Error | null) => void) {
callback(new Error("Internal Error"));
}
}
BonjourHolder.prototype._announcedOnMulticastSubnetWithCallback =
callbackify(BonjourHolder.prototype._announcedOnMulticastSubnet);
BonjourHolder.prototype._stop_announcedOnMulticastSubnetWithCallback =
callbackify(BonjourHolder.prototype._stop_announcedOnMulticastSubnet);
示例7: assert
// handle initial OpenSecureChannelRequest
this._process_certificates(message, (err: Error | null, statusCode?: StatusCode) => {
if (err) {
description = "Internal Error " + err.message;
return this._send_error(StatusCodes.BadInternalError, description, message, callback);
}
if (!statusCode) {
assert(false);
}
if (statusCode !== StatusCodes.Good) {
const description = "Sender Certificate Error";
console.log(chalk.cyan(description), chalk.bgRed.yellow(statusCode!.toString()));
// OPCUA specification v1.02 part 6 page 42 $6.7.4
// If an error occurs after the Server has verified Message security it shall return a ServiceFault instead
// of a OpenSecureChannel response. The ServiceFault Message is described in Part 4, 7.28.
return this._send_error(statusCode!, "", message, callback);
}
this._handle_OpenSecureChannelRequest(message, callback);
});
}
}
import { ObjectRegistry } from "node-opcua-object-registry";
ServerSecureChannelLayer.registry = new ObjectRegistry({});
(ServerSecureChannelLayer as any).prototype.checkCertificateCallback =
callbackify((ServerSecureChannelLayer as any).prototype.checkCertificate);
示例8: RegisterServerXResponse
const response = new RegisterServerXResponse({
configurationResults
});
return response;
}
}
/*== private
* returns true if the serverType can be added to a discovery server.
* @param serverType
* @return {boolean}
* @private
*/
function _isValidServerType(serverType: ApplicationType): boolean {
switch (serverType) {
case ApplicationType.Client:
return false;
case ApplicationType.Server:
case ApplicationType.ClientAndServer:
case ApplicationType.DiscoveryServer:
return true;
}
return false;
}
(OPCUADiscoveryServer as any).prototype.__internalRegisterServerWithCallback =
callbackify((OPCUADiscoveryServer as any).prototype.__internalRegisterServer);
exports.OPCUADiscoveryServer = OPCUADiscoveryServer;