PubSubPublishOptions Class - Flutter
Properties
persist
-
type:
bool -
defaultValue:
false -
This property specifies whether to store messages on server for upcoming participants.
-
If the value of this property is true, then server will store pubsub messages for the upcoming participants. They receive the stored messages on the
onOldMessagesReceivedcallback of the listener they pass tosubscribe().
sendOnly
-
type:
List<String> -
defaultValue:
[] -
If you want to send a message to specific participants, you can pass their respective
participantIdhere. If you don't provide any IDs, the message is sent to everyone subscribed to the topic.
note
A participant listed in sendOnly receives the message only if they are subscribed to that topic.
Example
// Send to two participants only, without storing the message
const options = PubSubPublishOptions(
sendOnly: ["participant-id-1", "participant-id-2"],
);
try {
await room.pubSub.publish("CHAT", "Hello", options);
} catch (e) {
print("publish failed: $e");
}
Got a Question? Ask us on discord

