@rxap/nest-socket-io-client
Version:
This package provides a NestJS module for integrating a Socket.IO client. It offers a client proxy service and a provider for managing the Socket.IO client connection, allowing NestJS applications to easily interact with Socket.IO servers.
35 lines (34 loc) • 1.33 kB
TypeScript
import { BehaviorSubject, Subject } from 'rxjs';
import { Socket } from 'socket.io-client';
export declare enum DisconnectReason {
/**
* The server has forcefully disconnected the socket with socket.disconnect()
*/
IO_SERVER_DISCONNECT = "io server disconnect",
/**
* The socket was manually disconnected using socket.disconnect()
*/
IO_CLIENT_DISCONNECT = "io client disconnect",
/**
* The server did not send a PING within the pingInterval + pingTimeout range
*/
PING_TIMEOUT = "ping timeout",
/**
* The connection was closed (example: the user has lost connection, or the network was changed from WiFi to 4G)
*/
TRANSPORT_CLOSE = "transport close",
/**
* The connection has encountered an error (example: the server was killed during a HTTP long-polling cycle)
*/
TRANSPORT_ERROR = "transport error"
}
export declare class SocketIoClientProvider {
readonly disconnected$: Subject<DisconnectReason>;
readonly connected$: Subject<void>;
readonly isConnected$: BehaviorSubject<boolean>;
private readonly logger;
private readonly config;
private socket?;
getSocket: () => Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>;
private connect;
}