declare const InterApplicationBus: any; /** * Instance created to enable use of a channel as a provider. Allows for communication with the {@link Channel#ChannelClient ChannelClients} by invoking an action on * a single client via {@link Channel#ChannelProvider#dispatch dispatch} or all clients via {@link Channel#ChannelProvider#publish publish} * and to listen for communication from clients by registering an action via {@link Channel#ChannelProvider#register register}. * * ##### Constructor * * Returned by {@link InterApplicationBus.Channel.create Channel.create}. * * ##### Synchronous Methods * * {@link Channel#ChannelProvider#onConnection onConnection(listener)} * * {@link Channel#ChannelProvider#onDisconnection onDisconnection(listener)} * * {@link Channel#ChannelProvider#publish publish(action, payload)} * * {@link Channel#ChannelProvider#register register(action, listener)} * * {@link Channel#ChannelProvider#remove remove(action)} * * ##### Asynchronous Methods * * {@link Channel#ChannelProvider#destroy destroy()} * * {@link Channel#ChannelProvider#dispatch dispatch(to, action, payload)} * * {@link Channel#ChannelProvider#getAllClientInfo getAllClientInfo()} * * ##### Middleware * Middleware functions receive the following arguments: (action, payload, senderId). * The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction * unless it is undefined, in which case the most recently defined payload is used. Middleware can be used for side effects. * * {@link Channel#ChannelProvider#setDefaultAction setDefaultAction(middleware)} * * {@link Channel#ChannelProvider#onError onError(middleware)} * * {@link Channel#ChannelProvider#beforeAction beforeAction(middleware)} * * {@link Channel#ChannelProvider#afterAction afterAction(middleware)} * * @memberof! Channel# * @hideconstructor * @property {InterApplicationBus.Channel~ClientIdentity[]} connections a read-only array containing all the identities of connecting clients. * */ declare class ChannelProvider { /** * * Destroy the channel. * @returns {Promise} * @tutorial ChannelProvider.destroy */ destroy(): void; /** * * Dispatch an action to a specified client. Returns a promise for the result of executing that action on the client side. * @param {InterApplicationBus.Channel~ClientIdentity} to - Identity of the target client. * @param {string} action - Name of the action to be invoked by the client. * @param {*} payload - Payload to be sent along with the action. * @returns {Promise} * @tutorial Channel.dispatch */ dispatch(): void; /** * * Register an action to be called * @param {string} action - Name of the action to be registered for channel clients to later invoke. * @param {Channel#ChannelProvider~Action} listener - Function representing the action to be taken on a client dispatch. * @returns {boolean} - Boolean representing the successful registration of the action. * @tutorial Channel.register */ register(): void; /** * * Publish an action and payload to every connected client. * Synchronously returns an array of promises for each action (see dispatch). * @param {string} action * @param {*} payload * @returns {Array>} * @tutorial ChannelProvider.publish */ publish(): void; /** * * Register a listener that is called on every new client connection. * It is passed the identity of the connecting client and a payload if it was provided to {@link Channel.connect}. * If you wish to reject the connection, throw an error. Be sure to synchronously provide an onConnection upon receipt of the channelProvider * to ensure all potential client connections are caught by the listener. * @param {Channel#ChannelProvider~ConnectionListener} listener * @returns {void} * @tutorial ChannelProvider.onConnection */ onConnection(): void; /** * * Register a listener that is called on every new client disconnection. * It is passed the disconnection event of the disconnecting client. * @param {InterApplicationBus.Channel~ConnectionEvent} listener * @returns {void} * @tutorial Channel.onDisconnection */ onDisconnection(): void; /** * * Register middleware that fires before the action. * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed before invoking the action. * @returns {void} * @tutorial ChannelMiddleware.beforeAction */ beforeAction(): void; /** * * Register an error handler. This is called before responding on any error. * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed in case of an error. * @returns {void} * @tutorial ChannelMiddleware.onError */ onError(): void; /** * * Register middleware that fires after the action. This is passed the return value of the action. * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed after invoking the action. * @returns {void} * @tutorial ChannelMiddleware.afterAction */ afterAction(): void; /** * * Remove an action by action name. * @param {string} action - Name of the action to be removed. * @returns {void} * @tutorial Channel.remove */ remove(): void; /** * * Sets a default action. This is used any time an action that has not been registered is invoked. * Default behavior if not set is to throw an error. * @param {Channel#ChannelProvider~Middleware} middleware - Function to be executed when a client invokes an action name that has not been registered. * @returns {void} * @tutorial ChannelMiddleware.setDefaultAction */ setDefaultAction(): void; /** Returns an array with info on every Client connected to the Provider * @returns { Promise> } * @tutorial Channel.getAllClientInfo */ getAllClientInfo(): void; } /** * Instance created to enable use of a channel as a client. Allows for communication with the * {@link Channel#ChannelProvider ChannelProvider} by invoking an action on the * provider via {@link Channel#ChannelClient#dispatch dispatch} and to listen for communication * from the provider by registering an action via {@link Channel#ChannelClient#register register}. * * ##### Constructor * Returned by {@link InterApplicationBus.Channel.connect Channel.connect}. * * ##### Synchronous Methods * * {@link Channel#ChannelClient#onDisconnection onDisconnection(listener)} * * {@link Channel#ChannelClient#register register(action, listener)} * * {@link Channel#ChannelClient#remove remove(action)} * * ##### Asynchronous Methods * * {@link Channel#ChannelClient#disconnect disconnect()} * * {@link Channel#ChannelClient#dispatch dispatch(action, payload)} * * ##### Middleware * Middleware functions receive the following arguments: (action, payload, senderId). * The return value of the middleware function will be passed on as the payload from beforeAction, to the action listener, to afterAction * unless it is undefined, in which case the original payload is used. Middleware can be used for side effects. * * {@link Channel#ChannelClient#setDefaultAction setDefaultAction(middleware)} * * {@link Channel#ChannelClient#onError onError(middleware)} * * {@link Channel#ChannelClient#beforeAction beforeAction(middleware)} * * {@link Channel#ChannelClient#afterAction afterAction(middleware)} * * @hideconstructor * @memberof! Channel# * @property {InterApplicationBus.Channel~ProviderIdentity} providerIdentity a read-only provider identity */ declare class ChannelClient { /** * * Disconnect from the channel. * @tutorial Channel.disconnect * @returns {Promise} */ disconnect(): void; /** * * Dispatch the given action to the channel provider. Returns a promise that resolves with the response from the provider for that action. * @param {string} action - Name of the action to be invoked by the channel provider. * @param {*} payload - Payload to be sent along with the action. * @tutorial Channel.dispatch * @returns {Promise} */ dispatch(): void; /** * * Register an action to be called by the provider of the channel. * @param {string} action - Name of the action to be registered for the channel provider to later invoke. * @param {Channel#ChannelClient~Action} listener - Function representing the action to be taken on a provider dispatch. * @returns {boolean} * @tutorial Channel.register */ register(): void; /** * * Register middleware that fires before the action. * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed before invoking the action. * @returns {void} * @tutorial ChannelMiddleware.beforeAction */ beforeAction(): void; /** * * Register a listener that is called on channel disconnection. * It is passed the disconnection event of the disconnecting channel. * @param {InterApplicationBus.Channel~ConnectionEvent} listener * @returns {void} * @tutorial Channel.onDisconnection */ onDisconnection(): void; /** * Register an error handler. This is called before responding on any error. * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed in case of an error. * @returns {void} * @tutorial ChannelMiddleware.onError */ onError(): void; /** * * Register middleware that fires after the action. This is passed the return value of the action. * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed after invoking the action. * @returns {void} * @tutorial ChannelMiddleware.afterAction */ afterAction(): void; /** * * Remove an action by action name. * @param {string} action - Name of the action to be removed. * @returns {void} * @tutorial Channel.remove */ remove(): void; /** * * Sets a default action. This is used any time an action that has not been registered is invoked. * Default behavior if not set is to throw an error. * @param {Channel#ChannelClient~Middleware} middleware - Function to be executed when a client invokes an action name that has not been registered. * @returns {void} * @tutorial ChannelMiddleware.setDefaultAction */ setDefaultAction(): void; } /** * Channel action callback signature * @callback Channel#ChannelProvider~Action * @param {any} payload - Payload sent along with the message. * @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the sender. */ /** * Channel action callback signature * @callback Channel#ChannelClient~Action * @param {any} payload - Payload sent along with the message. * @param {Identity} identity - Identity of the sender. */ /** * Middleware function signature * @callback Channel#ChannelProvider~Middleware * @param {string} action - Action to be invoked. * @param {any} payload - Payload sent along with the message (or error for error middleware). * @param {Identity} identity - Identity of the sender. */ /** * Middleware function signature * @callback Channel#ChannelClient~Middleware * @param {string} action - Action to be invoked. * @param {any} payload - Payload sent along with the message (or error for error middleware). * @param {Identity} identity - Identity of the sender. */ /** * Callback for the channel onConnection or onDisconnection. If it errors connection will be rejected. * @callback Channel#ChannelProvider~ConnectionListener * @param {InterApplicationBus.Channel~ClientIdentity} identity - Identity of the client attempting to connect to the channel. * @param {any} payload - Payload sent with connection request. */ /** * @REMOVED * Callback for onChannelConnect or onChannelDisconnect. * @typedef {object} InterApplicationBus.Channel~ConnectionEvent * @property {string} channelId - Identifier of the channel. * @property {string} uuid - Channel provider uuid. * @property {string} [name] - Channel provider name. * @property {string} channelName - Name of the channel. */ /** * @PORTED * Protocol values for determining channel messaging strategy. * @typedef {('classic' | 'rtc')} InterApplicationBus.Channel~MessagingProtocols - EXPERIMENTAL * */ /** * @PORTED * Channel provider creation options. * @typedef {object} InterApplicationBus.Channel~ChannelCreateOptions * @property {InterApplicationBus.Channel~MessagingProtocols[]} [protocols=['classic']] - EXPERIMENTAL: Messaging protocols supported by the channel provider. * */ /** * @PORTED * Options provided on a client connection to a channel. * @typedef {object} InterApplicationBus.Channel~ChannelConnectOptions * @property {InterApplicationBus.Channel~MessagingProtocols[]} [protocols=['classic']] - EXPERIMENTAL: Messaging protocols requested by the client, connection will fail if the provider protocols are not compatible. * @property {any} [payload] - Payload to pass to ChannelProvider onConnection action. * @property {boolean} [wait=true] - If true will wait for ChannelProvider to connect. If false will fail if ChannelProvider is not found. * */ /** * @PORTED * Provider Identity. * @typedef {object} InterApplicationBus.Channel~ProviderIdentity * @property {string} uuid - Channel provider uuid. * @property {string} [name] - Channel provider name. * @property {string} channelId - Identifier of the channel. * @property {boolean} [isExternal] - true if it's external connection. * @property {string} channelName - Name of the channel. * */ /** * @PORTED * Client Identity. * @typedef {object} InterApplicationBus.Channel~ClientIdentity * @property {string} uuid - Channel client uuid. * @property {string} name - Channel client name. * @property {string} endpointId - Unique identifier for a client, because there can be multiple clients at one name/uuid entity. * */ /** * @PORTED * Extended Client Information * @typedef {object} InterApplicationBus.Channel~ClientInfo * @property {string} uuid - Channel client uuid * @property {string} name - Channel client name * @property {string} endpointId - Unique identifier for a client, because there can be multiple clients at one name/uuid entity. * @property {string} entityType - Indicates if the client belongs to a Window or View * @property {string} connectionUrl - URL of the View or Window at the time of connection to the Channel Provider. */