本文整理汇总了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')
});
});