Participants
A participant represents a user in a conversation. To add a user to a conversation you can create a participant, and you can delete a participant to kick them. You can track the participants of a conversation in real-time using ConversationRef.subscribeParticipants.
participantRef.set(data): Unit
Parameters
interface SetParticipantParams
Parameters you can pass when updating a participant.
Properties that are undefined will not be changed. To clear / reset a property to the default, pass null.
The level of access the participant should have in the conversation. Default = "ReadWrite" access.
When the participant should be notified about new messages in this conversation. Default = ReadWrite access.
false means no notifications, true means notifications for all messages, and "MentionsOnly" means that the user will only be notified when they are mentioned with an @.
Returns
participantRef.edit(data): Unit
Parameters
interface SetParticipantParams
Parameters you can pass when updating a participant.
Properties that are undefined will not be changed. To clear / reset a property to the default, pass null.
The level of access the participant should have in the conversation. Default = "ReadWrite" access.
When the participant should be notified about new messages in this conversation. Default = ReadWrite access.
false means no notifications, true means notifications for all messages, and "MentionsOnly" means that the user will only be notified when they are mentioned with an @.
Returns
participantRef.createIfNotExists(data): Unit
Parameters
interface CreateParticipantParams
Parameters you can pass when creating a participant (adding a user to a conversation).
The level of access the participant should have in the conversation. Default = "ReadWrite" access.
When the participant should be notified about new messages in this conversation. Default = true
false means no notifications, true means notifications for all messages, and "MentionsOnly" means that the user will only be notified when they are mentioned with an @.
Returns
participantRef.delete(): Unit
Returns
A snapshot of a participant's attributes at a given moment in time.
The user who this Participant Snapshot is referring to
The level of access this participant has in the conversation.
When the participant will be notified about new messages in this conversation.
false means no notifications, true means notifications for all messages, and "MentionsOnly" means that the user will only be notified when they are mentioned with an @.
The date that this user joined the conversation, as a unix timestamp in milliseconds.
A subscription to the participants in a specific conversation.
Get a ParticipantSubscription by calling {@link ConversationRef.subscribeParticipants}
The subscription is 'windowed'. It includes everyone who joined since a certain point in time. By default, you subscribe to the 10 most recent participants, and any participants who joined after you subscribe.
You can expand this window by calling {@link ParticipantSubscription.loadMore}, which extends the window further into the past. Do not call .loadMore in a loop until you have loaded all participants, unless you know that the maximum number of participants is small (under 100).
Remember to .unsubscribe the subscription once you are done with it.
The current state of the subscription
An object with the following fields:
type is one of "pending", "active", "unsubscribed", or "error".
When type is "active", includes latestSnapshot and loadedAll.
latestSnapshot: ParticipantSnapshot[] | null the current state of the participants in the window, or null if you're not a participant in the conversation
loadedAll: boolean true when latestSnapshot contains all the participants in the conversation
When type is "error", includes the error field. It is a JS Error object explaining what caused the subscription to be terminated.
Resolves when the subscription starts receiving updates from the server.
Wait for this promise if you want to perform some action as soon as the subscription is active.
The promise rejects if the subscription is terminated before it connects.
Resolves when the subscription permanently stops receiving updates from the server.
This is either because you unsubscribed or because the subscription encountered an unrecoverable error.
Expand the window to include older participants
Calling loadMore multiple times in parallel will still only load one page of participants.
Avoid calling .loadMore in a loop until you have loaded all participants. If you do need to call loadMore in a loop, make sure you set a small upper bound (e.g. 100) on the number of participants, where the loop will exit.
Unsubscribe from this resource and stop receiving updates.
If the subscription is already in the "unsubscribed" or "error" state, this is a no-op.