interface message {
use wasi:io/poll@0.2.4.{pollable};
use common.{blob, blob-result};
// Represents a subscription to a broadcast topic
resource subscription {
// Pollable to check for new messages on the topic
pollable: func() -> pollable;
// Retrieves a new message from the topic, if available
get: func() -> option<string>;
// Cancels the subscription
unsubscribe: func();
}
// Result of an async receive operation
resource receive-result {
// Pollable to check readiness
pollable: func() -> pollable;
// Retrieves the message if available; None if not ready
get: func() -> option<string>;
}
// Sends a message to the remote user client
send: func(message: string);
// Receives an incoming message from the remote user client
receive: func() -> receive-result;
send-blob: func(blob: blob);
receive-blob: func() -> blob-result;
// Publishes a message to a topic (broadcast to all subscribers)
broadcast: func(topic: string, message: string);
// Subscribes to a topic and returns a subscription handle
subscribe: func(topic: string) -> subscription;
}