The topic to which the message will be published.
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: objectAdditional data to be sent along with the message.
This method can be used to subscribe to a specific topic and receive messages published under that topic.
The provided callback function is executed whenever a new message is received for the subscribed topic.
The topic to subscribe to.
A function that handles incoming messages for the subscribed topic.
A promise that resolves with previously published messages, if message persistence was enabled for the topic.
The topic from which to unsubscribe.
The same callback function that was provided when subscribing to the topic.