/// import EventEmitter from "eventemitter3"; import { ReadyState, SocketType, StreamEvent } from "./types"; export default interface ISocket extends EventEmitter void; }> { type: SocketType; readonly id: string; readonly sessionId: string; readonly writable: boolean; readonly readable: boolean; readonly remoteAddress: string; readonly remotePort: number; readonly localAddress: string; readonly localPort: number; readonly destroyed: boolean; readonly readyState: ReadyState; readonly readableLength: number; readonly writableLength: number; /** 是否暂停 */ isPaused(): boolean; /** * 读取数据 * @param ttl 超时时间,单位毫秒ms,默认为0=不超时 */ read(ttl: number): Promise; /** * 往网络里写数据 * @param socket 网络连接socket * @param chunk 数据 * @param callback 写完之后回调,并告知写子多少内容, (chunkSize: number)=>{} */ write(chunk: Buffer | string, ...args: any[]): boolean; end(chunk?: Buffer | string, ...args: any[]): any; pipe(socket: ISocket): ISocket; /** * 暂停读写 */ pause(): void; /** * 恢复读写 */ resume(): void; destroy(err?: Error): void; close(err?: Error): void; setKeepAlive(enable: boolean, initialDelay: number): void; }