import UserPresence from './user-presence'; import type { Filter } from './types'; /** * @description * Exposes APIs for websocket Messaging Service. * @public */ declare class MessagingServiceManager { /** * { * "": * } */ static subscribers: { [key: string]: any; }; static connectionsCount: number; static webSocket: any; static connectionConfig: { [key: string]: any; } | null; static inProgressSubscriptions: { [key: string]: any; }[]; static inProgressMessages: any[]; static isServiceAlive: boolean | null; static serviceAliveHandler: NodeJS.Timeout | null; static userPresence: UserPresence; static refreshB2SOffset: number; private static tokenExpiryTime; private static reInitInterval?; /** * Initializing the connection to message service. * @param config object to initialize connection to messaging service * example: * { * messagingService: "ws://localhost:3000/c11n-msg" * } * @private */ static initConnection(config?: { messagingService?: string; } | null): void; static handleOnError(event: any): void; static handleOnClose(event: any): void; static handleOnOpen(): void; static handleOnMessage(event: { data: string; }): void; /** * Api to reInitialize connection on abrupt closing of connection or ALIVE message not received in specified time. * @param skipSetInterval passed true if broadcast message not received in given time period * @private */ static reInitialization(skipSetInterval?: boolean): void; /** * Api to check server liveliness broadcast message based on time passed as argument, to receive recurring ALIVE message on network * @param timeToPing time in ms. * @private */ static checkLiveliness(timeToPing: number): void; /** * Sets the messaging service url * @param connectionConfig service url to be connected for websocket. * eq., * { * messagingService: "ws://localhost:3000/c11n-msg" * } * @private */ static setConnectionConfig(connectionConfig: { [key: string]: any; }): void; /** * Api to remove all listener attached on websocket * @private */ static cleanSocketListeners(): void; /** * Api to clean and nullify websocket * @private */ static disconnect(): void; /** * Api to subscribe to messaging service and depends on the filter creteria messages will * be forwarded to subscribers. * @param filter Object to hold filter creteria, * It helps to receive only targetted changes. * eq., * 1. * { * matcher: "interaction" * } * * 2. * { * matcher: "pulse", * filter: { * caseId: "EPIC-201" * } * } * @param messageHandler callback handler * @param contextName - Name of the context eq., app/primary_1 * @param id any specific id or id will be autogenerated. Id can be used for unsubscribing from * message service. * @example Example subscribe() * Example usage - PCore.getMessagingServiceManager().subscribe({matcher: "interaction"}, message => { * // Do process message here * }); * @returns returns the subscription id, can be used for unsubscribing from * message service. * @public */ static subscribe(filter: Filter, messageHandler: Function, contextName?: string, id?: string): string; /** * Subscribes to socket. * @param messageSubscriber message subscriber * @param id subscriber id * @private */ static subscribeToSocket(messageSubscriber: { [key: string]: any; }, id: string): void; /** * Removes the handler from subscriptions and disconnects from service. * @param id Pass id returned by subscribe method. * @example Example unsubscribe() * const subId = PCore.getMessagingServiceManager().subscribe({matcher: "interaction"}, message => { * // Do process message here * })); * PCore.getMessagingServiceManager().unsubscribe(subId); * @public */ static unsubscribe(id: string): void; /** * Publishes the message to subscribers received from server. * @param message message object received from messaging service. * @private */ static publishMessage(message: object): void; static getUserPresence: () => UserPresence; static getCaseSubscription: (caseId: string) => import("./atomic-subscription").default; static refreshB2STokenReInit: () => Promise; static getTokenExpiryTime: () => number; static setTokenExpiryTime: (token: { tokenExpiryTime: number; }) => void; /** * Removes the cache of all subscribers. * @param contextName name of the context. * @private */ static clearContext(contextName: string): void; } export default MessagingServiceManager;