UNPKG

691 BTypeScriptView Raw
1import { Buffer } from 'buffer';
2import { Socket } from 'net';
3export declare abstract class TcpSocket {
4 readonly socket: Socket;
5 private isClosed;
6 get netSocket(): Socket;
7 constructor(socket: Socket);
8 connect(port: number, host: string): this;
9 on(event: string, callback: (err?: any) => void): this;
10 once(event: string, callback: (err?: any) => void): this;
11 end(): this;
12 sendMessage(message: any, callback?: (err?: any) => void): void;
13 protected abstract handleSend(message: any, callback?: (err?: any) => void): any;
14 private onData;
15 protected abstract handleData(data: Buffer | string): any;
16 protected emitMessage(data: string): void;
17}