import { TOPIC, Message } from '../constants'; import { SocketWrapper, DeepstreamServices, DeepstreamConfig } from '@deepstream/types'; /** * The MessageDistributor routes valid and permissioned messages to * various, previously registered handlers, e.g. event-, rpc- or recordHandler */ export default class MessageDistributor { private services; private callbacks; constructor(options: DeepstreamConfig, services: DeepstreamServices); /** * Accepts a socketWrapper and a parsed message as input and distributes * it to its subscriber, based on the message's topic */ distribute(socketWrapper: SocketWrapper, message: Message): void; /** * Allows handlers (event, rpc, record) to register for topics. Subscribes them * to both messages passed to the distribute method as well as messages received * from the messageConnector */ registerForTopic(topic: TOPIC, callback: (message: Message) => void): void; /** * Whenever a message from the messageConnector is received it is passed * to the relevant handler, but with null instead of * a socketWrapper as sender */ private onMessageConnectorMessage; }