Private
#privatePrivate
acknowledgementPrivate
acknowledgementsPrivate
causalReadonly
channelPrivate
filterPrivate
handlersPrivate
incomingPrivate
lamportPrivate
localPrivate
outgoingPrivate
receivedPrivate
receivedPrivate
tasksPrivate
timePrivate
_receivePrivate
_sendPrivate
_sendOptional
callback: ((message) => Promise<{ Optional
options: boolean | AddEventListenerOptionsPrivate
deliverPrivate
executePrivate
getconst channel = new MessageChannel("my-channel");
// Queue some operations
await channel.sendMessage(payload, callback);
channel.receiveMessage(incomingMessage);
// Process all queued operations
await channel.processTasks();
Will emit a 'taskError' event if any task fails, but continues processing remaining tasks
Queues a received message for processing.
The message will be processed when processTasks() is called, ensuring proper dependency resolution and causal ordering.
The message to receive and process
const channel = new MessageChannel("chat-room");
// Receive a message from the network
channel.receiveMessage(incomingMessage);
// Process the received message
await channel.processTasks();
Optional
listener: null | EventHandler<MessageChannelEvents[K]>Optional
options: boolean | EventListenerOptionsPrivate
reviewOptional
detail: CustomEventInit<Detail>Private
safeOptional
eventInit: CustomEventInit<any>Sends a short-lived message without synchronization or reliability requirements.
Sends a message without a timestamp, causal history, or bloom filter. Ephemeral messages are not added to the outgoing buffer. Upon reception, ephemeral messages are delivered immediately without checking for causal dependencies or including in the local log.
The payload to send.
Optional
callback: ((message) => Promise<boolean>)A callback function that returns a boolean indicating whether the message was sent successfully.
Queues a message to be sent on this channel.
The message will be processed sequentially when processTasks() is called. This ensures proper lamport timestamp ordering and causal history tracking.
The message content as a byte array
Optional
callback: ((message) => Promise<{ Optional callback function called after the message is processed
Promise that resolves when the message is queued (not sent)
const channel = new MessageChannel("chat-room");
const message = new TextEncoder().encode("Hello, world!");
await channel.sendMessage(message, async (processedMessage) => {
console.log("Message processed:", processedMessage.messageId);
return { success: true };
});
// Actually send the message
await channel.processTasks();
Send a sync message to the SDS channel.
Increments the lamport timestamp, constructs a Message
object
with an empty load. Skips outgoing buffer, filter, and local log.
Optional
callback: ((message) => Promise<boolean>)A callback function that returns a boolean indicating whether the message was sent successfully.
Static
get
Processes all queued tasks sequentially to ensure proper message ordering.
This method should be called periodically by the library consumer to execute queued send/receive operations in the correct sequence.