import { EventEmitter } from '@herbcaudill/eventemitter42'; /** * Receives numbered inbound messages and emits them in order. If a message is missing after a delay, asks * for it to be sent (or resent). * * Numbers and sends outbound messages, and responds to requests for missing messages. */ export declare class MessageQueue extends EventEmitter> { #private; constructor({ sendMessage, timeout }: Options); /** * Messages can be received before the service is started (e.g. while waiting to be ready to send * over the network). They will be emitted in order when start() is called. */ start(): this; /** * Stop emitting messages. Messages will be queued until start() is called again. */ stop(): this; /** * Assigns a number to the message and sends it. */ send(message: T): this; /** * Resends a message that was previously sent. */ resend(index: number): this; /** * Queues inbound messages and, if we're started, emits them in order. */ receive(message: NumberedMessage): this; } export type NumberedMessage = T & { index: number; }; export type MessageQueueEvents = { message: (message: NumberedMessage) => void; request: (index: number) => void; }; type Options = { /** Send function */ sendMessage: (message: NumberedMessage) => void; /** Time to wait (in ms) before requesting a missing message */ timeout?: number; }; export {}; //# sourceMappingURL=MessageQueue.d.ts.map