UNPKG

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