import type { BroadcastEvent, ChannelAuthorizationCallback } from './types'; import type { BroadcastServer } from './server'; import type { BroadcastTo, Broadcaster } from './broadcaster'; import type { ChannelManager } from './channels'; /** * Global broadcast helper function * * @example * // Broadcast an event class * await broadcast(new OrderShipped(order)) * * // Broadcast directly with channel, event, data * broadcast('orders', 'OrderCreated', { id: 1 }) * * // Broadcast to private channel * broadcast('private-orders.123', 'OrderUpdated', { status: 'shipped' }) */ export declare function broadcast(event: BroadcastEvent): Promise; export declare function broadcast(channel: string, event: string, data?: TData): void; /** * Broadcast to a specific user * * @example * broadcastToUser(123, 'NotificationReceived', { message: 'Hello!' }) */ export declare function broadcastToUser(userId: string | number, event: string, data: TData): void; /** * Broadcast to multiple users * * @example * broadcastToUsers([1, 2, 3], 'Announcement', { message: 'Hello everyone!' }) */ export declare function broadcastToUsers(userIds: Array, event: string, data: TData): void; /** * Define channel authorization (can be used outside of class context) * * @example * // In routes/channels.ts * channel('private-orders.{orderId}', (socket, { orderId }) => { * return socket.data.user?.id === getOrderOwnerId(orderId) * }) */ export declare function channel(pattern: string, callback: ChannelAuthCallback): void; /** * Channel authorization callback type * Re-exported from types for convenience */ export type ChannelAuthCallback = ChannelAuthorizationCallback; /** * Broadcast Facade - Laravel-style static API * * @example * // Set up the server instance first * Broadcast.setServer(server) * * // Define channel authorization * Broadcast.channel('private-orders.{orderId}', (socket, { orderId }) => { * return socket.data.user?.id === getOrderOwnerId(orderId) * }) * * // Broadcast events * Broadcast.send('orders', 'OrderCreated', { id: 1 }) * * // Or use event classes * Broadcast.event(new OrderShipped(order)) */ export declare class Broadcast { static setServer(server: BroadcastServer): void; static getServer(): BroadcastServer | null; static get broadcaster(): Broadcaster; static get channels(): ChannelManager; static channel(pattern: string, callback: ChannelAuthCallback): typeof Broadcast; static event(event: BroadcastEvent): Promise; static send(channels: string | string[], event: string, data: TData): void; static presence(channel: string, event: string, data: TData): void; static toUser(userId: string | number, event: string, data: TData): void; static toUsers(userIds: Array, event: string, data: TData): void; static toOthers(socketId: string): BroadcastTo; static getConnectionCount(): number; static getSubscriberCount(channel: string): number; }