@nestjs/microservices
Version:
Microservices for NestJS: message and event handlers over Kafka, RabbitMQ, NATS, Redis, MQTT, gRPC or TCP.
33 lines (32 loc) • 1.31 kB
TypeScript
import { Buffer } from 'buffer';
import { Socket } from 'net';
export declare abstract class TcpSocket {
readonly socket: Socket;
private isClosed;
get netSocket(): Socket;
constructor(socket: Socket);
connect(port: number, host: string): this;
on(event: string, callback: (err?: any) => void): this;
once(event: string, callback: (err?: any) => void): this;
end(): this;
/**
* Asks the socket to emit no further messages until "resumeMessages" is
* called. "ServerTCP" does so while "maxConcurrentMessages" messages of the
* peer are being handled. A socket class that does not implement it keeps
* emitting messages as it reads them.
*/
pauseMessages(): void;
resumeMessages(): void;
sendMessage(message: any, callback?: (err?: any) => void): void;
protected abstract handleSend(message: any, callback?: (err?: any) => void): any;
private onData;
/**
* Surfaces a framing error on the underlying socket and closes it.
* Pass "destroy" for a peer that cannot be trusted to answer a FIN.
*/
protected handleDataError(e: any, { destroy }?: {
destroy?: boolean | undefined;
}): void;
protected abstract handleData(data: Buffer | string): any;
protected emitMessage(data: string): void;
}