import { BrowserTypes } from '@finos/fdc3'; import { IRootPublisher } from '../contracts.internal.js'; import { EventListenerLookup, FullyQualifiedAppIdentifier } from '../contracts.js'; /** * responds to all channel related Request messages * stores all state for channels across all agents and proxies */ export declare class ChannelMessageHandler { private messagingProvider; private currentUserChannels; private userChannels; private appChannels; private privateChannels; private readonly privateChannelEventListeners; private readonly contextListeners; protected readonly contextListenerCallbacks: Map void>; constructor(messagingProvider: IRootPublisher); addListenerCallback(callbackUuid: string, listenerCallback: (source: FullyQualifiedAppIdentifier, contextType: string | null) => void): Promise; removeListenerCallback(callbackUuid: string): Promise; private onContextListenerCreation; onGetUserChannelsRequest(requestMessage: BrowserTypes.GetUserChannelsRequest, source: FullyQualifiedAppIdentifier): void; onGetCurrentChannelRequest(requestMessage: BrowserTypes.GetCurrentChannelRequest, source: FullyQualifiedAppIdentifier): void; onJoinUserChannelRequest(requestMessage: BrowserTypes.JoinUserChannelRequest, source: FullyQualifiedAppIdentifier, eventListeners: EventListenerLookup): void; onLeaveCurrentChannelRequest(requestMessage: BrowserTypes.LeaveCurrentChannelRequest, source: FullyQualifiedAppIdentifier, eventListeners: EventListenerLookup): void; /** * Checks whether source app is listening for ChannelChangedEvents on given channel */ private isListeningForChannelChangedEvent; /** * Publishes a ChannelChangedEvent to the origin app * @param newChannelId is the channelId of the user channel the user has joined or null if the user is now not joined to a user channel; * @param messagingProvider is used to publish the event * @param source is the appIdentifier of the origin app */ private publishChannelChangedEvent; onPrivateChannelAddEventListenerRequest(requestMessage: BrowserTypes.PrivateChannelAddEventListenerRequest, source: FullyQualifiedAppIdentifier): void; onPrivateChannelUnsubscribeEventListenerRequest(requestMessage: BrowserTypes.PrivateChannelUnsubscribeEventListenerRequest, source: FullyQualifiedAppIdentifier): void; onCreatePrivateChannelRequest(requestMessage: BrowserTypes.CreatePrivateChannelRequest, source: FullyQualifiedAppIdentifier): void; /** * Used by root desktop agent to add app receiving private channel in RaiseIntentResultResponse to private channel's allowedList * @param channelId is id of private channel * @param app is appIdentifier of app being added to allowedList */ addToPrivateChannelAllowedList(channelId: string, app: FullyQualifiedAppIdentifier): void; onGetOrCreateChannelRequest(requestMessage: BrowserTypes.GetOrCreateChannelRequest, source: FullyQualifiedAppIdentifier): void; onAddContextListenerRequest(requestMessage: BrowserTypes.AddContextListenerRequest, source: FullyQualifiedAppIdentifier): void; /** * Returns given channelId or 'currentChannel' if channelId is null */ private convertToContextListenerIndex; /** * Returns true if given channel is a user or app channel, or if given app is allowed to listen and publish on given private channel. Returns false otherwise */ private isAppAllowedOnChannel; /** * Publish privateChannelOnAddContextListenerEvent to all apps who are listening for them on given private channel */ private publishPrivateChannelOnAddContextListenerEvent; onContextListenerUnsubscribeRequest(requestMessage: BrowserTypes.ContextListenerUnsubscribeRequest, source: FullyQualifiedAppIdentifier): void; /** * Publish privateChannelOnUnsubscribeEvent for given contextListener to all apps who are listening for them on given private channel */ private publishPrivateChannelOnUnsubscribeEvent; /** * Returns predicate function that selects listeners based on their channelId */ private getListenersByChannelId; /** * Returns appIdentifiers of all apps which are listening for given PrivateChannelEvent and whose eventListener fulfills given predicate * @param eventType is type of event being listened for * @param predicate is predicate that needs to be fulfilled by eventListener */ private getAppsListeningForPrivateChannelEvent; onBroadcastRequest(requestMessage: BrowserTypes.BroadcastRequest, source: FullyQualifiedAppIdentifier): void; /** * Publishes a broadcastEvent to all apps which are listening for broadcastEvents of the correct contextType on the given channel */ private publishBroadcastEvent; /** * Returns all appIdentifiers for apps which are listening for broadcastEvents of the correct contextType on given channel, excluding origin app * @param requestMessage is broadcastRequest message containing context to be broadcast and channelId of channel to broadcast it on * @param source is appIdentifier of origin app */ private getBroadcastAppIdentifiers; /** * Returns all appIdentifiers associated with contextListeners that listen for given contextType, excluding those for origin app * @param contextListener is contextListener being checked * @param contextType is type of context listener should be listening for * @param source is appIdentifier of origin app */ private isListenerValidBroadcastTarget; /** * Adds the given context to the context history of the given channel */ private addContextToChannelHistory; /** * Updates context history of a channel * @param channelHistoryPair is the channel and context history combination of the channel whose history is being updated * @param context is the context being added to the history * @returns updated channel context history combination */ private updateChannelHistory; onGetCurrentContextRequest(requestMessage: BrowserTypes.GetCurrentContextRequest, source: FullyQualifiedAppIdentifier): void; onPrivateChannelDisconnectRequest(requestMessage: BrowserTypes.PrivateChannelDisconnectRequest, source: FullyQualifiedAppIdentifier): void; /** * Unsubscribes given contextListener if it belongs to given origin app */ private unsubscribePrivateChannelContextListener; /** * Publish privateChannelOnDisconnectEvent to all apps who are listening for them on given private channel, excluding app which is disconnecting from channel */ private publishPrivateChannelOnDisconnectEvent; /** * Clean up all channel subscriptions for a disconnected proxy * @param appId The app ID of the disconnected proxy */ cleanupDisconnectedProxy(appId: FullyQualifiedAppIdentifier): void; /** * Removes the app from the currentUserChannels mapping if present. * @param appId The app ID of the disconnected proxy */ private removeFromCurrentUserChannels; /** * Cleans up all context listeners associated with the disconnected app, and publishes unsubscribe events for private channels. * @param appId The app ID of the disconnected proxy */ private cleanupContextListeners; /** * Cleans up all private channel event listeners associated with the disconnected app. * @param appId The app ID of the disconnected proxy */ private cleanupEventListeners; /** * Cleans up private channel context history and allowed list for the disconnected app. * @param appId The app ID of the disconnected proxy */ private cleanupPrivateChannels; /** * Cleans up user channel context history for the disconnected app. * @param appId The app ID of the disconnected proxy */ private cleanupUserChannelContexts; }