publish method
- String topic,
- String message, [
- PubSubPublishOptions? options,
- Map<
String, dynamic> payload = const {},
publish() is used to publish messages on a specified topic in the room.
Throws if the room has not been joined yet or the request fails.
Parameters
topic- This is the name of the topic, for which message will be published.message- This is the actual message.options- Whether to persist the message, and who to send it to — see PubSubPublishOptions.payload- If you need to include additional information along with a message, you can pass here asMap<String, dynamic>. This is optional parameter.
Example
// Publishing message
room.pubSub
.publish(
"CHAT",
"Hii",
const PubSubPublishOptions(persist: true),
);
Implementation
Future<void> publish(String topic, String message,
[PubSubPublishOptions? options,
Map<String, dynamic> payload = const {}]) =>
_publish(topic, message, options, payload);