Skip to content

@get-advantage/advantage / utils/messaging

Module: utils/messaging

Variables

ADVANTAGE

Const ADVANTAGE: "ADVANTAGE"

Defined in

src/utils/messaging.ts:3

Functions

sendMessageAndAwaitResponse

sendMessageAndAwaitResponse(message, messageChannel, timeout): Promise<AdvantageMessage>

Sends a message and awaits a response.

Parameters

NameTypeDescription
messagePartial<AdvantageMessage>The message to send.
messageChannelMessageChannelThe message channel to use for communication.
timeoutnumberThe timeout in milliseconds.

Returns

Promise<AdvantageMessage>

A promise that resolves with the response message.

Defined in

src/utils/messaging.ts:79


sendMessageAndOpenChannel

sendMessageAndOpenChannel(message, retryInterval?, maxAttempts?): Promise<{ messageChannel: MessageChannel ; reply: AdvantageMessage }>

Sends a message and opens a message channel to receive the reply.

Parameters

NameTypeDefault valueDescription
messagePartial<AdvantageMessage>undefinedThe message to send.
retryIntervalnumber200The interval (in milliseconds) between retry attempts. Default is 100ms.
maxAttemptsnumber25The maximum number of retry attempts. Default is 25.

Returns

Promise<{ messageChannel: MessageChannel ; reply: AdvantageMessage }>

A promise that resolves with the reply and the message channel.

Defined in

src/utils/messaging.ts:12