///
import { IncomingMessage } from 'node:http';
import z from 'zod';
import { WebSocket } from 'ws';
/**
* Channel is responsible for dispatching incoming and outgoing messages for a given topic.
*
* Examples:
*
* const channel = new Channel("session") // matches "session" only
* const channel = new Channel("session:*") // matches "session:123", "session:456", etc.
*
*/
export declare class Channel {
readonly topic: string;
readonly events: {
incoming: Record) => void;
}>;
outgoing: Record;
};
private wildcardMatch;
constructor(topic: string);
matches(topic: string): boolean;
incoming(event: string, schema: T, handler: (payload: z.infer) => void): this;
outgoing(event: string, schema: T): this;
}
export default class WebSocketServer {
private readonly channels;
private connections;
constructor();
onConnection(socket: WebSocket, request: IncomingMessage): void;
channel(topic: string): Channel;
broadcast(topic: string, event: string, payload: Record): void;
private handleIncomingMessage;
private findChannel;
private removeConnection;
}
//# sourceMappingURL=ws-client.d.mts.map