import { PresenceMessage } from '../../constants'; import { DeepstreamConfig, DeepstreamServices, SocketWrapper, StateRegistry, Handler, SubscriptionRegistry, ConnectionListener } from '@deepstream/types'; /** * This class handles incoming and outgoing messages in relation * to deepstream presence. It provides a way to inform clients * who else is logged into deepstream */ export default class PresenceHandler extends Handler implements ConnectionListener { private services; private metaData?; private localClients; private subscriptionRegistry; private connectedClients; constructor(config: DeepstreamConfig, services: DeepstreamServices, subscriptionRegistry?: SubscriptionRegistry, stateRegistry?: StateRegistry, metaData?: any | undefined); /** * The main entry point to the presence handler class. * * Handles subscriptions, unsubscriptions and queries */ handle(socketWrapper: SocketWrapper, message: PresenceMessage): void; /** * Called whenever a client has succesfully logged in with a username */ onClientConnected(socketWrapper: SocketWrapper): void; /** * Called whenever a client has disconnected */ onClientDisconnected(socketWrapper: SocketWrapper): void; private handleQueryAll; /** * Handles finding clients who are connected and splicing out the client * querying for users */ private handleQuery; /** * Alerts all clients who are subscribed to * PRESENCE_JOIN that a new client has been added. */ private onClientAdded; /** * Alerts all clients who are subscribed to * PRESENCE_LEAVE that the client has left. */ private onClientRemoved; }