UNPKG

@synet/realtime

Version:

Realtime Communication server/client implementations

32 lines (31 loc) 1.1 kB
import type { RealtimeProvider, RealtimeChannel, RealtimeProviderOptions, RealtimeEvent } from "@synet/patterns/realtime"; import type { NatsOptions } from "./nats-types"; /** * NATS-based implementation of RealtimeProvider */ export declare class NatsRealtimeProvider implements RealtimeProvider { readonly baseUrl: string; private options; private channels; constructor(baseUrl: string, options?: RealtimeProviderOptions<NatsOptions>); /** * Create a channel for the specified topic */ createChannel<TIn extends RealtimeEvent = RealtimeEvent, TOut extends RealtimeEvent = RealtimeEvent>(topic: string, options?: RealtimeProviderOptions<NatsOptions>): RealtimeChannel<TIn, TOut>; /** * Remove a channel */ removeChannel(channel: RealtimeChannel): Promise<void>; /** * Get all active channels */ getChannels(): RealtimeChannel[]; /** * Close all channels and clean up resources */ disconnect(): Promise<void>; /** * Create a NATS URL with topic as query parameter */ private getNatsUrl; }