import { Logger } from '../../common/utils'; import { BaseComponent } from '../base'; import { ComponentNames } from '../types'; import { Channel } from './channel'; import { RealtimePresence } from './presence'; import { RealtimeComponentSubscribe } from './types'; export declare class Realtime extends BaseComponent { private channel; protected logger: Logger; name: ComponentNames; private localParticipant; private state; private channels; private callbacksToSubscribeWhenJoined; participant: RealtimePresence; constructor(); /** * @function connect * @description - connect to a channel * @param name - channel name * @returns {Channel} */ connect(name: string): Promise; /** * @function subscribe * @description Subscribes to a specific event and registers a callback function to handle the received data. * If the channel is not yet available, the subscription will be queued and executed once the channel is joined. * @param event - The name of the event to subscribe to. * @param callback - The callback function to handle the received data. It takes a parameter of type `RealtimeMessage` or `string`. */ subscribe: RealtimeComponentSubscribe; /** * @function publish * @description Publishes an event with optional data to the channel. * @param event - The name of the event to publish. * @param data - Data to be sent along with the event. */ publish: (event: string, data: T) => void; /** * @function unsubscribe * @description Unsubscribes from a specific event. * @param event - The event to unsubscribe from. * @param callback - An optional callback function to be called when the event is unsubscribed. */ unsubscribe: RealtimeComponentSubscribe; protected start(): void; protected destroy(): void; /** * @function disconnectToAllChannels * @description - disconnect to all channels * @returns {void} */ private disconnectFromAllChannels; /** * @function changeState * @description change realtime component state and publish state to client * @param state * @returns {void} */ private changeState; }