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


TypeScript Socket.emit方法代码示例

本文整理汇总了TypeScript中net.Socket.emit方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Socket.emit方法的具体用法?TypeScript Socket.emit怎么用?TypeScript Socket.emit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.Socket的用法示例。


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

示例1: setTimeout

 setTimeout(() => {
     socket.emit('data', part1);
     setTimeout(() => {
         socket.emit('data', part2);
         setTimeout(() => {
             socket.emit('data', part3);
         }, 100);
     }, 100);
 }, 100);
开发者ID:Heresiarch88,项目名称:vscode-php-debug,代码行数:9,代码来源:dbgp.ts

示例2: it

 it('should error on invalid XML', () => new Promise((resolve, reject) => {
     conn.on('error', (error: Error) => {
         assert.isDefined(error);
         assert.instanceOf(error, Error);
         resolve();
     });
     conn.once('message', (document: XMLDocument) => {
         reject(new Error('emitted message event'));
     });
     socket.emit('data', makePacket('<</<<><>>><?><>'));
 }));
开发者ID:Heresiarch88,项目名称:vscode-php-debug,代码行数:11,代码来源:dbgp.ts

示例3: Promise

        return new Promise(async (resolve, reject) => {

            let videoData: any = await this.getVideoInfo(ytId);
            let redisFormatted = await this.formatForRedis('videos', ytId, videoData);
            // console.log('f', redisFormatted);
            redis.hmset(key, redisFormatted.videoId, redisFormatted.videoString, async (err) => {
                if (err) {
                    reject(err);
                }
                let addedVideo = await this.getById('videos', redisFormatted.videoId);
                resolve(addedVideo);
            });
            this.io.emit('VIDEOS_MESSAGE', { message: 'added' });
        });
开发者ID:andrrrl,项目名称:lantube,代码行数:14,代码来源:videos.ts

示例4: String

 redis.HDEL('videos', String(videoId), async (err, reply) => {
     if (err) {
         reject(err);
     }
     if (reply === 1) {
         let v = await this.getAll('videos');
         await this.reorderAll('videos');
         let added = await this.getById('videos', videoId);
         resolve(added);
     } else {
         resolve({
             message: reply
         });
     }
     this.io.emit('VIDEOS_MESSAGE', { message: 'deleted' });
 });
开发者ID:andrrrl,项目名称:lantube,代码行数:16,代码来源:videos.ts

示例5: while

client.on('data', (data: string) => {
  // First four characters indicate length
  data = remaining_code + data;
  const length = data.length;
  while (true) {
    const chunkLength = parseInt(data.substr(0, 4));
    if (isNaN(chunkLength) || chunkLength > length + 4) {
      remaining_code = data;
      break;
    }
    const chunk = data.substr(4, chunkLength);
    data = data.substr(4 + chunkLength);
    if (chunk.length > 0) {
      try {
        client.emit('event', JSON.parse(chunk));
      } catch (e) {
        console.log(`Could not parse event Json '${chunk}': ${e}`);
      }
    }
  }
});
开发者ID:lochbrunner,项目名称:charlie,代码行数:21,代码来源:index.ts

示例6: if

    });
    _socket = _socket.addListener("lookup", (err, address, family, host) => {
        error = err;

        if (typeof family === 'string') {
            str = family;
        } else if (typeof family === 'number') {
            num = family;
        }

        str = host;
    });
    _socket = _socket.addListener("timeout", () => { });

    /// emit
    bool = _socket.emit("close", bool);
    bool = _socket.emit("connect");
    bool = _socket.emit("data", buffer);
    bool = _socket.emit("drain");
    bool = _socket.emit("end");
    bool = _socket.emit("error", error);
    bool = _socket.emit("lookup", error, str, str, str);
    bool = _socket.emit("lookup", error, str, num, str);
    bool = _socket.emit("timeout");

    /// on
    _socket = _socket.on("close", had_error => {
        bool = had_error;
    });
    _socket = _socket.on("connect", () => { });
    _socket = _socket.on("data", data => {
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:31,代码来源:net.ts

示例7: processRequest

 processRequest(request: FacebookRequest, callback: ((err: any, info: any) => void)): void {
     let message = this.messageParser.parseMessage(request.message.text);
     message.sender = request.recipient;
     message.id = v1();
     this.endpoint.emit(JSON.stringify(message));
 };
开发者ID:yarrem,项目名称:facebookChatBotApi,代码行数:6,代码来源:facebookApiService.ts

示例8:

    this._outSocket.connect(term.conout, () => {
      // TODO: Emit event on agent instead of socket?

      // Emit ready event.
      this._outSocket.emit('ready_datapipe');
    });
开发者ID:sedwards2009,项目名称:extraterm,代码行数:6,代码来源:windowsPtyAgent.ts


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