2023-03-31 03:17:41 +02:00
|
|
|
import type { IDecodedMessage, IDecoder } from "./message.js";
|
2023-05-23 16:06:46 +05:30
|
|
|
import type { IAsyncIterator, PubSubTopic, Unsubscribe } from "./misc.js";
|
2023-03-31 03:17:41 +02:00
|
|
|
import type { Callback, ProtocolOptions } from "./protocols.js";
|
|
|
|
|
|
2023-05-23 16:06:46 +05:30
|
|
|
type ContentTopic = string;
|
|
|
|
|
|
2023-03-31 03:17:41 +02:00
|
|
|
export type ActiveSubscriptions = Map<PubSubTopic, ContentTopic[]>;
|
|
|
|
|
|
|
|
|
|
export interface IReceiver {
|
2023-05-09 20:15:37 +02:00
|
|
|
toSubscriptionIterator: <T extends IDecodedMessage>(
|
|
|
|
|
decoders: IDecoder<T> | IDecoder<T>[],
|
2023-08-16 20:18:13 +05:30
|
|
|
opts?: ProtocolOptions
|
2023-05-09 20:15:37 +02:00
|
|
|
) => Promise<IAsyncIterator<T>>;
|
2023-03-31 03:17:41 +02:00
|
|
|
subscribe: <T extends IDecodedMessage>(
|
|
|
|
|
decoders: IDecoder<T> | IDecoder<T>[],
|
|
|
|
|
callback: Callback<T>,
|
2023-08-16 20:18:13 +05:30
|
|
|
opts?: ProtocolOptions
|
2023-03-31 03:17:41 +02:00
|
|
|
) => Unsubscribe | Promise<Unsubscribe>;
|
|
|
|
|
}
|