OptionalbufferThis represents whether incoming messages are accumulated into the messages array.
true, messages are stored in messages and also delivered to
onMessageReceived and onOldMessagesReceived.false, messages are delivered only via onMessageReceived, onOldMessagesReceived and the
messages array is never populated. Useful for high-throughput topics
(e.g. thousands of messages per second) where retaining a re-rendering
array is undesirable.OptionalmaxThis represents the hard cap on the number of messages retained in the messages array.
null to retain every message.OptionalmaxThis represents the maximum number of message batches to queue when your internet is slow or your device can't keep up with the incoming rate. Increase this value to retain more messages and catch up after recovering. Max: 200.
This represents all persisted messages for the topic.
Unique identifier for the message.
The message content.
Optional additional data sent along with the message.
The ID of the participant who sent the message.
The display name of the participant who sent the message.
Timestamp indicating when the message was published.
The topic under which the message was published.
OptionalnewThis represents the maximum number of realtime messages to receive per 500 ms.
OptionaloldThis represents how many old messages to receive. Pass 0 to receive none. If omitted, all old messages are delivered.
OptionalrealtimeThis represents the behavior when your internet is slow or your device can't keep up with the incoming rate. RealtimeOverflow.QUEUE (default) queues the remaining messages so you receive them once you catch up; RealtimeOverflow.DROP drops them instead.
This represents the topic associated with the PubSub instance.
The message content to be published. This value must be a string.
Optionaloptions: { persist?: boolean; sendOnly?: String[] }
Optionalpersist?: booleanWhen set to true, the message is stored for the entire session and is available to newly joined participants.
OptionalsendOnly?: String[]An array of participantId that should receive the message. If not provided, the message is broadcast to all participants.
Optionalpayload: object
Additional data to be sent along with the message.
message is not a string or payload is not an objectonMessageReceived, grouped for bulk handling.info object describing how many messages were dropped.(messages, { isLast }) — isLast is true on the final batch of old messages.
usePubSubprovides reactive APIs to publish, subscribe, and access persisted messages for a specific topic within a meeting.The hook accepts three arguments:
topic— the topic name to publish and subscribe to.listeners— event callbacks (onMessageReceived,onBatchReceived,onOldMessagesReceived,onMessageDrop).properties— behavior config (maxMessages,bufferMessages,oldMessageLimit,realtimeOverflow,maxQueue,newMessageLimit).Throws
listenerscallback (onMessageReceived,onBatchReceived,onOldMessagesReceived,onMessageDrop) is not a function,maxQueuewas provided whilerealtimeOverflowis RealtimeOverflow.DROP, ornewMessageLimitis not greater than0/oldMessageLimitis less than0Example