Conversation
This API is in beta and subject to change.
Interface that manages a conversation.
Methods
update
fun update(callback: ): Unit
This API is in beta and subject to change.
Sends the conversation changes to the cloud. The changes are: title, public join flag and custom data.
Successful update happens if a participant is the owner (ConversationParticipant.isOwner is true).
To get the method call result use one of the following options:
- Specify the callback parameter to consume the results with ConversationEvent or ErrorEvent in case of success/error accordingly.
- Implement the MessengerListener.onEditConversation and MessengerListener.onError events.
Other parties of the conversation (online participants and logged in clients) can be informed about changing the title or custom data and enabling/disabling public join via the MessengerListener.onEditConversation event.
Parameters
callback:
OptionalCallback to be called when the function completes
Returns
type:
Unit
addParticipants
fun addParticipants(participants: List<ConversationParticipant>
, callback: ): Unit
This API is in beta and subject to change.
Adds new participants to the conversation.
It is possible only on the following conditions:
- the participants are users of the main Voximplant developer account or its child accounts
- the current user can manage other participants (ConversationParticipant.canManageParticipants is true)
- the conversation is not a direct one (Conversation.isDirect is false)
Duplicated users are ignored. Causes ErrorEvent if at least one user does not exist or already belongs to the conversation.
To get the method call result use one of the following options:
- Specify the callback parameter to consume the results with ConversationEvent or ErrorEvent in case of success/error accordingly.
- Implement the MessengerListener.onEditConversation and MessengerListener.onError events.
Other parties of the conversation (online participants and logged in clients) can be informed about adding participants via the MessengerListener.onEditConversation event.
Parameters
participants:
List<ConversationParticipant>
List of ConversationParticipant to be added to the conversation.
callback:
OptionalCallback to be called when the function completes
Returns
type:
Unit
removeParticipants
fun removeParticipants(participants: List<ConversationParticipant>
, callback: ): Unit
This API is in beta and subject to change.
Removes participants from the conversation.
It is possible only on two conditions:
- the current user can manage other participants (ConversationParticipant.canManageParticipants is true).
- the conversation is not a direct one (Conversation.isDirect is false)
Duplicated users are ignored. Causes ErrorEvent if at least one user:
- does not exist
- is already removed
Note that you can remove participants that are marked as deleted (User.isDeleted is true).
The removed users can later get this conversation's UUID via the User.leaveConversationUuidList method.
To get the method call result use one of the following options:
- Specify the callback parameter to consume the results with ConversationEvent or ErrorEvent in case of success/error accordingly.
- Implement the MessengerListener.onEditConversation and MessengerListener.onError events.
Other parties of the conversation (online participants and logged in clients) can be informed about removing participants via the MessengerListener.onEditConversation event.
Parameters
participants:
List<ConversationParticipant>
List of ConversationParticipant to be removed from the conversation.
callback:
OptionalCallback to be called when the function completes
Returns
type:
Unit
editParticipants
fun editParticipants(participants: List<ConversationParticipant>
, callback: ): Unit
This API is in beta and subject to change.
Edits participants' permissions. It is possible only if the current user can manage other participants (ConversationParticipant.canManageParticipants is true).
Duplicated users are ignored. Causes ErrorEvent if at least one user does not exist or belong to the conversation.
To get the method call result use one of the following options:
- Specify the callback parameter to consume the results with ConversationEvent or ErrorEvent in case of success/error accordingly.
- Implement the MessengerListener.onEditConversation and MessengerListener.onError events.
Other parties of the conversation (online participants and logged in clients) can be informed about editing participants via the MessengerListener.onEditConversation event.
Parameters
participants:
List<ConversationParticipant>
List of ConversationParticipant to be edited in the conversation.
callback:
OptionalCallback to be called when the function completes
Returns
type:
Unit
sendMessage
fun sendMessage(text: String?
, payload: List<Map<String, Any>>?
, callback: ): Unit
This API is in beta and subject to change.
Sends a message to the conversation.
Sending messages is available only for participants that have write permissions (ConversationParticipant.canWrite is true).
To get the method call result use one of the following options:
- Specify the callback parameter to consume the results with MessageEvent or ErrorEvent in case of success/error accordingly.
- Implement the MessengerListener.onSendMessage and MessengerListener.onError events.
Other parties of the conversation (online participants and logged in clients) can be informed about sending messages to the conversation via the MessengerListener.onSendMessage event.
To be informed about sending messages while being offline, participants can subscribe to the MessengerNotification.OnSendMessage messenger push notification.
TODO(Oleg) Update documentation to use text or payload as non-null for at least one of the parameters
Parameters
text:
String?
OptionalMessage text, maximum 5000 characters
payload:
List<Map<String, Any>>?
OptionalMessage payload
callback:
OptionalCallback to be called when the function completes
Returns
type:
Unit
retransmitEvents
fun retransmitEvents(eventsFrom: Long
, eventsTo: Long
, callback: ): Unit
This API is in beta and subject to change.
Requests events in the specified sequence range to be sent from the cloud to this client.
Only ConversationEvent and MessageEvent events can be retransmitted; any other events cannot be retransmitted.
Use this method to get history or missed events in case of network disconnect. Client should use this method to request all events based on the last event sequence received from the cloud and last event sequence saved locally (if any).
The maximum number of retransmitted events per method call is 100. Requesting more than 100 events causes ErrorEvent.
If the current user quits a Conversation.isUber conversation, messages that are posted during the user's absence are not retransmitted later.
To get the method call result use one of the following options:
- Specify the callback parameter to consume the results with RetransmitEvent or ErrorEvent in case of success/error accordingly.
- Implement the MessengerListener.onRetransmitEvents and MessengerListener.onError events.
Parameters
eventsFrom:
Long
First event in sequence range, inclusive
eventsTo:
Long
Last event in sequence range, inclusive
callback:
OptionalCallback to be called when the function completes
Returns
type:
Unit
retransmitEventsFrom
fun retransmitEventsFrom(eventsFrom: Long
, count: Int
, callback: ): Unit
This API is in beta and subject to change.
Requests a number of events starting with the specified sequence to be sent from the cloud to this client.
Only ConversationEvent and MessageEvent events can be retransmitted; any other events cannot be retransmitted.
Use this method to get history or get missed events in case of network disconnect. Client should use this method to request all events based on the last event sequence received from the cloud and last event sequence saved locally (if any).
The maximum number of retransmitted events per method call is 100. Requesting more than 100 events cause an ErrorEvent.
If the current user quits a Conversation.isUber conversation, messages that are posted during the user's absence are not retransmitted later.
The result contains maximum available events for the current user even if It is less than the specified count value. To get the method call result use one of the following options:
- Specify the callback parameter to consume the results with RetransmitEvent or ErrorEvent in case of success/error accordingly.
- Implement the MessengerListener.onRetransmitEvents and MessengerListener.onError events.
Parameters
eventsFrom:
Long
First event in sequence range, inclusive
count:
Int
Number of events
callback:
OptionalCallback to be called when the function completes
Returns
type:
Unit
retransmitEventsTo
fun retransmitEventsTo(eventsTo: Long
, count: Int
, callback: ): Unit
This API is in beta and subject to change.
Requests a number of events up to the specified sequence to be sent from the cloud to this client.
Only ConversationEvent and MessageEvent events can be retransmitted; any other events cannot be retransmitted.
Use this method to get history or get missed events in case of network disconnect. Client should use this method to request all events based on the last event sequence received from the cloud and last event sequence saved locally (if any).
The maximum number of retransmitted events per method call is 100. Requesting more than 100 events cause ErrorEvent.
If the current user quits a Conversation.isUber conversation, messages that are posted during the user's absence are not retransmitted later.
The result contains maximum available events for the current user even if It is less than the specified count value. To get the method call result use one of the following options:
- Specify the callback parameter to consume the results with RetransmitEvent or ErrorEvent in case of success/error accordingly.
- Implement the MessengerListener.onRetransmitEvents and MessengerListener.onError events.
Parameters
eventsTo:
Long
Last event in sequence range, inclusive
count:
Int
Number of events
callback:
OptionalCallback to be called when the function completes
Returns
type:
Unit
typing
fun typing(callback: ): Unit
This API is in beta and subject to change.
Informs the cloud that the user is typing some text.
The method calls within 10s interval from the last call cause ErrorEvent.
To get the method call result use one of the following options:
- Specify the callback parameter to consume the results with ConversationServiceEvent or ErrorEvent in case of success/error accordingly.
- Implement the MessengerListener.onTyping and MessengerListener.onError events.
Other parties of the conversation (online participants and logged in clients) can be informed about typing via the MessengerListener.onTyping event.
Parameters
callback:
OptionalCallback to be called when the function completes
Returns
type:
Unit
markAsRead
fun markAsRead(sequence: Long
, callback: ): Unit
This API is in beta and subject to change.
Marks the event with the specified sequence as read.
A method call with the specified sequence makes the ConversationParticipant.lastReadEventSequence method return this sequence, i.e., such sequences can be get for each participant separately.
If the sequence parameter specified less than 1, the method marks all the events as unread (for this participant) except the event with the sequence equals to '1'.
To get the method call result use one of the following options:
- Specify the callback parameter to consume the results with ConversationServiceEvent or ErrorEvent in case of success/error accordingly.
- Implement the MessengerListener.isRead and MessengerListener.onError events.
Other parties of the conversation (online participants and logged in clients) can be informed about marking events as read via the MessengerListener.isRead event.
Parameters
sequence:
Long
Sequence number of the event in the conversation to be marked as read. Should not be greater than currently possible
callback:
OptionalCallback to be called when the function completes
Returns
type:
Unit
Props
createdTime
val createdTime: Long
This API is in beta and subject to change.
The UNIX timestamp (seconds) that specifies the time of the conversation creation.
Returns
type:
Long
customData
var customData: Map<String, Any>?
This API is in beta and subject to change.
The custom data of the conversation, up to 5kb.
Note that changing this property does not send changes to the cloud. Use Conversation.update to send all changes at once.
Returns
type:
Map<String, Any>?
isDirect
val isDirect: Boolean
This API is in beta and subject to change.
Whether the conversation is direct.
A direct conversation cannot be uber and/or public.
There can be only 2 participants in a direct conversation which is unique and the only one for these participants. There cannot be more than 1 direct conversation for the same 2 users.
If one of these users tries to create a new direct conversation with the same participant via Messenger.createConversation, the method returns the UUID of the already existing direct conversation.
Returns
type:
Boolean
participants
val participants: List<ConversationParticipant>
This API is in beta and subject to change.
The list of participants with their permissions.
Returns
type:
List<ConversationParticipant>
isPublicJoin
var isPublicJoin: Boolean
This API is in beta and subject to change.
Whether a conversation is public or not. If true, anyone can join the conversation by UUID.
A public conversation cannot be direct.
Note that changing this property does not send changes to the cloud. Use Conversation.update to send all changes at once
Returns
type:
Boolean
title
var title: String
This API is in beta and subject to change.
The title of the current conversation.
Note that changing this property does not send changes to the cloud. Use Conversation.update to send all changes at once.
Returns
type:
String
uuid
val uuid: String
This API is in beta and subject to change.
The universally unique identifier (UUID) of this conversation.
Returns
type:
String
lastUpdateTime
val lastUpdateTime: Long
This API is in beta and subject to change.
The UNIX timestamp (seconds) that specifies the time when one of ConversationEvent or MessageEvent has been last provoked event in this conversation.
Returns
type:
Long
lastSequence
val lastSequence: Long
This API is in beta and subject to change.
The sequence of the last event in the conversation.
Returns
type:
Long
isUber
val isUber: Boolean
This API is in beta and subject to change.
Whether the conversation is uber.
An uber conversation cannot be direct.
Users in a uber conversation are not able to retrieve messages that are posted to the conversation after they quit.
Returns
type:
Boolean