本文整理汇总了TypeScript中ws.send函数的典型用法代码示例。如果您正苦于以下问题:TypeScript send函数的具体用法?TypeScript send怎么用?TypeScript send使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
this.gpg.changeCard(cc, (res: Result) => {
console.log('run:-6', m.header.action);
ws.send(Message.prepare(header, Progress.info(res.stdOut)));
ws.send(Message.prepare(header, Progress.error(res.stdErr)));
ws.send(Message.prepare(header.setAction('ChangeCard.Completed')));
// send cardlist
});
示例2:
this.gpg.deletePublicKey(payload.fpr, (rs: Result) => {
myws.send(Message.prepare(header, Progress.info(rs.stdOut)));
myws.send(Message.prepare(header, Progress.error(rs.stdErr)));
myws.send(
Message.prepare(header, Progress.ok('DeleteKey Successfull', true))
);
});
示例3: run
public run(observer: Observer, ws: WebSocket, m: Message.Message): boolean {
console.log('GpgChangeCard.run', m.header);
if (m.header.action != 'ChangeCard.Request') {
// ws.send(Message.prepare('Progressor.Clavator', Progress.fail('Ohh')))
return false;
}
const a = JSON.parse(m.data) || {};
const cc = ChangeCard.fill(a);
console.log('run:-1', m.header.action);
// console.log(m, a, kg)
// console.log(kg.valid(), kg.errText())
const header = Message.toHeader(m, 'Progressor.Clavator');
console.log('run:-2', m.header.action);
if (!cc.valid) {
console.log('run:-3', m.header.action, cc);
ws.send(Message.prepare(header, Progress.fail('Failed received ChangeCard is not valid')));
return;
}
// console.log('>>>', kg.masterCommand())
console.log('run:-4', m.header.action);
ws.send(Message.prepare(header, Progress.info(`ChangeCard Action`)));
console.log('run:-5', m.header.action);
this.gpg.changeCard(cc, (res: Result) => {
console.log('run:-6', m.header.action);
ws.send(Message.prepare(header, Progress.info(res.stdOut)));
ws.send(Message.prepare(header, Progress.error(res.stdErr)));
ws.send(Message.prepare(header.setAction('ChangeCard.Completed')));
// send cardlist
});
return true;
}
示例4: switch
ws.on('message', (message) => {
console.log('received: %s', message);
try {
let msg:ISocketMessage = JSON.parse(message)
console.log("Message OK")
console.log(msg.event)
switch(msg.event) {
case "folder": {
fc.handle(msg, ws)
break;
}
case "image": {
ic.handle(msg, ws)
break;
}
default: {
ws.send(JSON.stringify({event: "error", message: "event not recognized"}))
}
}
//ws.send(JSON.stringify({event: "ok", payload: ""}))
} catch (err) {
ws.send(JSON.stringify({event: "error", message: err.message}))
}
});
示例5:
gpg.createSubkey(fpr, ki, ki.subKeys.get(cnt), (res: Result) => {
// console.log('createSubKeys:4');
ws.send(Message.prepare(header, Progress.info(res.stdOut)));
ws.send(Message.prepare(header, Progress.error(res.stdErr)));
// console.log('createSubKeys:5');
this.createSubKeys(gpg, header, ws, cnt + 1, fpr, ki, cb);
});
示例6: send
function send(data: string | ArrayBuffer) {
if (typeof data !== 'string') {
socket.send(new Buffer(data));
} else {
socket.send(data);
}
}
示例7:
this.gpg.changePin(rcp.action, rcp, (res: Result) => {
if (res.exitCode != 0) {
ws.send(Message.prepare(header, Progress.fail(res.stdOut + '\n' + res.stdErr)));
} else {
ws.send(Message.prepare(header, Progress.ok(`pin for ${rcp.action} changed`, true)));
}
ws.send(Message.prepare(header.setAction('GpgChangePinYubikey.Completed'), null));
});
示例8: sendKeysToCard
private sendKeysToCard(
observer: Observer,
ws: WebSocket,
header: Message.Header,
ksk: SecretKey,
syk: SimpleYubikey,
idx = 0
): void {
if (idx == 0) {
console.log('start-suspend observer');
observer.suspend();
}
if (idx >= ksk.subKeys.length) {
ws.send(Message.prepare(header.setAction('SimpleYubiKey.Completed')));
console.log('completed-resume observer');
observer.resume();
return;
}
const subkey = ksk.subKeys[idx];
ws.send(
Message.prepare(
header,
Progress.ok(`start keyToYubiKey for ${subkey.fingerPrint.fpr}:${idx}`)
)
);
this.gpg.keyToYubiKey(
syk.asKeyToYubiKey(subkey.fingerPrint.fpr, idx + 1),
(res: Result) => {
if (res.exitCode != 0) {
console.error('error-resume observer', res, res.runQueue[0]);
// observer.resume();
ws.send(
Message.prepare(
header,
Progress.fail(res.stdOut + '\n' + res.stdErr)
)
);
} else {
ws.send(
Message.prepare(
header,
Progress.ok(
`keyToYubiKey for ${subkey.fingerPrint.fpr}:${idx} changed`,
true
)
)
);
this.sendKeysToCard(observer, ws, header, ksk, syk, idx + 1);
}
}
);
}
示例9:
this.gpg.resetYubikey((res: Result) => {
// ws.send(Message.prepare(header, res));
if (res.stdOut.split('\n').find((i: string) => { return i.startsWith('ERR '); })) {
res.stdOut.split('\n').forEach((s: string) => {
ws.send(Message.prepare(header, Progress.fail(s)));
});
} else {
ws.send(Message.prepare(header,
Progress.ok('Almost done. Remove your Yubikey now and plug it in again.', true)));
// res.stdOut.split('\n').forEach((s: string) => {
// ws.send(Message.prepare('Progressor.Clavator', Progress.ok(s)))
// })
}
ws.send(Message.prepare(header.setAction('GpgResetYubikey.Completed'), null));
});
示例10: if
() => {
if (socket.readyState === WebSocket.OPEN) {
socket.send('')
} else if (socket.readyState === WebSocket.CLOSED) {
clearInterval(timer)
}
},