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


TypeScript Socket.read方法代码示例

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


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

示例1: AuthConfirmation

          this.link.once('readable', () => {
            let chunk: Buffer = this.link.read()
            if (!chunk) return;
            let resp = new AuthConfirmation(chunk);

            if (resp.success){
              this.link.on('readable', () => this.dataChunker(this.link.read()));
              resolve(null);
            }
            else
              throw new Error('Auth failed to whip server')
          });
开发者ID:M-O-S-E-S,项目名称:mgm,代码行数:12,代码来源:Whip.ts

示例2: sock_readable

	private sock_readable(options) {
		let chunk = this._sock.read();

		if (!chunk) {
			this.resolve(null);
			return;
		}

		if (this._tail) {
			chunk = chunk ? Buffer.concat([this._tail, chunk], this._tail.length + chunk.length) : this._tail;
			this._tail = null;
		}

		let tail = this.processChunk(chunk, options.data);

		if (tail.length)
			this._tail = tail;

		// if no data has been processed - receive and process more data
		if (this.isPending)
			this._sock.once("readable", this.sock_readable.bind(this, options));
	}
开发者ID:dcby,项目名称:smtp-receiver,代码行数:22,代码来源:Loop.ts

示例3: AuthChallenge

        this.link.once('readable', () => {
          let chunk: Buffer = this.link.read()
          if (!chunk) return;

          let ch = new AuthChallenge(chunk);
          let r = new AuthResponse(this.password, ch);

          this.link.write(r.response);

          // read once for auth response
          this.link.once('readable', () => {
            let chunk: Buffer = this.link.read()
            if (!chunk) return;
            let resp = new AuthConfirmation(chunk);

            if (resp.success){
              this.link.on('readable', () => this.dataChunker(this.link.read()));
              resolve(null);
            }
            else
              throw new Error('Auth failed to whip server')
          });
        });
开发者ID:M-O-S-E-S,项目名称:mgm,代码行数:23,代码来源:Whip.ts


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