helene
Version:
Real-time Web Apps for Node.js
30 lines (29 loc) • 1.04 kB
TypeScript
import { Server } from './server';
import { ClientNode } from './client-node';
import { ServerChannel } from './server-channel';
export type EventOptions = {
protected?: boolean;
/**
* Only allow user to subscribe to this event on his own channel. Automatically makes the event protected.
*/
user?: boolean;
/**
* This overrides the `user` flag.
*/
shouldSubscribe?: (client: ClientNode, eventName: string, channel: string) => Promise<boolean>;
/**
* This will propagate the event to other instances when running node in a cluster.
*/
cluster?: boolean;
};
export declare class Event {
uuid: string;
name: string;
isProtected: boolean;
channel: ServerChannel;
server: Server;
cluster: boolean;
shouldSubscribe: (client: ClientNode, eventName: string, channel: string) => Promise<boolean>;
constructor(name: string, server: Server, channel: ServerChannel, opts?: EventOptions);
handler(channel: ServerChannel, params: Record<string, any>): void;
}