• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ws.send函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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
 });
开发者ID:mabels,项目名称:clavator,代码行数:7,代码来源:gpg-change-card.ts


示例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))
   );
 });
开发者ID:mabels,项目名称:clavator,代码行数:7,代码来源:delete-secret-key.ts


示例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;
 }
开发者ID:mabels,项目名称:clavator,代码行数:31,代码来源:gpg-change-card.ts


示例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}))
     }
     
 });
开发者ID:aheinrich,项目名称:websocket-image-server,代码行数:30,代码来源:server.ts


示例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);
 });
开发者ID:mabels,项目名称:clavator,代码行数:7,代码来源:create-key-set-task.ts


示例6: send

	function send(data: string | ArrayBuffer) {
		if (typeof data !== 'string') {
			socket.send(new Buffer(data));
		} else {
			socket.send(data);
		}
	}
开发者ID:Agamnentzar,项目名称:ag-sockets,代码行数:7,代码来源:serverSocket.ts


示例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));
 });
开发者ID:mabels,项目名称:clavator,代码行数:8,代码来源:gpg-change-pin-yubikey.ts


示例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);
       }
     }
   );
 }
开发者ID:mabels,项目名称:clavator,代码行数:52,代码来源:send-key-to-yubikey.ts


示例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));
 });
开发者ID:mabels,项目名称:clavator,代码行数:15,代码来源:gpg-reset-yubikey.ts


示例10: if

 () => {
     if (socket.readyState === WebSocket.OPEN) {
         socket.send('')
     } else if (socket.readyState === WebSocket.CLOSED) {
         clearInterval(timer)
     }
 },
开发者ID:nicolasstucki,项目名称:dotty,代码行数:7,代码来源:tracer.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ws.terminate函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ws.on函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap