當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。