import { Participant } from '../../common/types/participant.types'; import { Logger, Observable } from '../../common/utils'; import { IOC } from '../../services/io'; import { RealtimeMessage, RealtimePublish, RealtimeChannelSubscribe } from './types'; import { RealtimePresence } from './presence'; export declare class Channel extends Observable { private name; private ioc; private channel; protected logger: Logger; private state; private localParticipant; private callbacksToSubscribeWhenJoined; participant: RealtimePresence; constructor(name: string, ioc: IOC, localParticipant: Participant, connectionLimit: number | 'unlimited'); disconnect(): Promise; /** * @function publish * @description Publishes an event with data to the channel. * @param event - The name of the event to publish. * @param data - Data to be sent along with the event. */ publish: RealtimePublish; /** * @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: RealtimeChannelSubscribe; /** * @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: RealtimeChannelSubscribe; /** * @function changeState * @description change realtime component state and publish state to client * @param state * @returns {void} */ private changeState; private subscribeToRealtimeEvents; /** * @function fetchHistory * @description get realtime client data history * @returns {RealtimeMessage | Record} */ fetchHistory: (eventName?: string) => Promise | null>; /** * @function publishEventToClient * @description - publish event to client * @param event - event name * @param data - data to publish * @returns {void} */ private publishEventToClient; }