/// import { EventEmitter } from "events"; import { IConnection } from "./transmission/connection"; import { IChannel } from "./transmission/channel"; import { LiquidTapConfigInput, LiquidTapConfig } from "./domain/liquid-tap-config"; import { AuthType, ConnectedEventData, handlerType, WsEvent } from "./domain"; export interface ITapClient { connected(): boolean; subscribe(channelName: string, payload?: any): IChannel; sendEvent(eventName: string, data: any, channelName?: string): Promise; bind(event: string, handler: handlerType): Promise | void; authenticate(auth: AuthType): Promise; unsubscribe(channelName: string): boolean; removeChannel(name: string): void; getChannel(name: string, createIfNotExists?: boolean, subPayload?: any): IChannel | null; destroy(): void; identity: string; options: LiquidTapConfig; } export declare class TapClient implements ITapClient { options: LiquidTapConfig; channels: Array; connection: IConnection; authenticated: boolean; authenticating: boolean; authenticationPending: boolean; authenticationTimer: any; authRetryTimer: any; authRetryAttempts: number; tagReconnection: boolean; pendingChannels: any; eventEmitter: EventEmitter; /** * Unique identifier * Intended to be used for some entropy in non-cryptographic deterministic hashes. * (ie, every time the same thing is hashed with this identity, it should be the same) */ identity: string; constructor(options?: LiquidTapConfigInput, connection?: IConnection); connected(): boolean; subscribe(channelName: string, payload?: any): IChannel; sendEvent(eventName: string, data: any, channelName?: string): Promise; bind(event: string, handler?: handlerType): Promise | void; authenticate(auth: AuthType): Promise; unsubscribe(channelName: string): boolean; removeChannel(name: string): void; getChannel(name: string, createIfNotExists?: boolean, subPayload?: any): IChannel | null; destroy(): void; _sendAuthentication(jwt: string): Promise; _authenticationTimeout(): void; _handleTick(dataObj: WsEvent): void; _handleConnected({ reconnect }: ConnectedEventData): void; _handleDisconnected(): void; _handleUnavailable(): void; _handleFailed(): void; _handleAuthSuccess(): void; _handleAuthFailure(data: any): void; _canSubscribeNow(channel: IChannel): boolean; _subscribeAllWaiting(queue: string): void; /** * Checks if the required information is present, then attempts authentication and schedules retries if it fails. * * Returns a promise which resolves when the auth either succeeds or fails. */ _maybeAuthenticateWithRetry(): Promise; /** * Performs a single authentication attempt. */ _attemptAuthOnce(): Promise; /** * Schedules another authention attempt if the retry limit isn't exceeded */ _maybeScheduleAuthRetry(): void; _bindConnection(): void; }