本文整理匯總了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')
});
示例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));
}
示例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')
});
});