VIConversation
Interface that may be used to manage a conversation.
Methods
addParticipants
Future<VIConversationEvent>
addParticipants( participants)
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 (VIConversation.direct is false) Duplicated users are ignored. Causes VIException if at least one user does not exist or already belongs to the conversation.
Other parties of the conversation (online participants and logged in clients) can be informed about adding participants via the VIMessenger.onEditConversation callback.
Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError
Parameters
participants:
List of VIConversationParticipant to be added to the conversation. Should not contain null(s), be null or empty list.
Returns
type:
Future<VIConversationEvent>
editParticipants
Future<VIConversationEvent>
editParticipants( participants)
Edits participants permissions. It is possible only if the current user can manage other participants (VIConversationParticipant.canManageParticipants is true).
Duplicated users are ignored. Causes VIException if at least one user does not exist or belong to the conversation.
Other parties of the conversation (online participants and logged in clients) can be informed about editing participants via the VIMessenger.onEditConversation callback.
Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError
Parameters
participants:
List of VIConversationParticipant to be edited in the conversation. Should not contain null(s), be null or empty list.
Returns
type:
Future<VIConversationEvent>
markAsRead
Future<VIConversationServiceEvent>
markAsRead(int
sequence)
Marks the event with the specified sequence as read.
A method call with the specified sequence makes the VIConversationParticipant.lastReadSequence property 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'.
Other parties of the conversation (online participants and logged in clients) can be informed about marking events as read via the VIMessenger.onRead callback.
Throws VIException, if operation failed, otherwise returns VIConversationServiceEvent instance. For all possible errors see VIMessagingError
Parameters
sequence:
int
Sequence number of the event in the conversation to be marked as read. Should not be greater than currently possible.
Returns
type:
Future<VIConversationServiceEvent>
removeParticipants
Future<VIConversationEvent>
removeParticipants( participants)
Removes participants from the conversation.
It is possible only on two conditions:
- the current user can manage other participants (VIConversationParticipant.canManageParticipants is true).
- the conversation is not a direct one (VIConversation.direct is false)
Duplicated users are ignored. Causes VIException if at least one user:
- does not exist
- is already removed
Note that you can remove participants that are marked as deleted (VIUser.isDeleted is true).
The removed users can later get this conversation's UUID via the VIUser.leaveConversationList property.
Other parties of the conversation (online participants and logged in clients) can be informed about removing participants via the VIMessenger.onEditConversation callback.
Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError
Parameters
participants:
List of VIConversationParticipant to be removed from the conversation. Should not contain null(s), be null or empty list.
Returns
type:
Future<VIConversationEvent>
retransmitEvents
Future<VIRetransmitEvent>
retransmitEvents(int
from, int
to)
Requests events in the specified sequence range to be sent from the cloud to this client.
Only VIConversationEvent and VIMessageEvent events can be retransmitted; any other events cannot be retransmitted.
The method is used 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 VIException.
If the current user quits a VIConversation.uber conversation, messages that are posted during the user's absence are not retransmitted later.
Throws VIException, if operation failed, otherwise returns VIRetransmitEvent instance. For all possible errors see VIMessagingError
Parameters
from:
int
First event in sequence range, inclusive
to:
int
Last event in sequence range, inclusive
Returns
type:
Future<VIRetransmitEvent>
retransmitEventsFrom
Future<VIRetransmitEvent>
retransmitEventsFrom(int
from, int
count)
Requests a number of events starting with the specified sequence to be sent from the cloud to this client.
Only VIConversationEvent and VIMessageEvent events can be retransmitted; any other events cannot be retransmitted.
The method is used 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 VIException.
If the current user quits a VIConversation.uber conversation, messages that are posted during the user's absence are not retransmitted later.
Throws VIException, if operation failed, otherwise returns VIRetransmitEvent instance. For all possible errors see VIMessagingError
Parameters
from:
int
First event in sequence range, inclusive
count:
int
Number of events
Returns
type:
Future<VIRetransmitEvent>
retransmitEventsTo
Future<VIRetransmitEvent>
retransmitEventsTo(int
to, int
count)
Requests a number of events up to the specified sequence to be sent from the cloud to this client.
Only VIConversationEvent and VIMessageEvent events can be retransmitted; any other events cannot be retransmitted.
The method is used 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 VIException.
If the current user quits a VIConversation.uber conversation, messages that are posted during the user's absence are not retransmitted later.
Throws VIException, if operation failed, otherwise returns VIRetransmitEvent instance. For all possible errors see VIMessagingError
Parameters
to:
int
Last event in sequence range, inclusive
count:
int
Number of events
Returns
type:
Future<VIRetransmitEvent>
sendMessage
Future<VIMessageEvent>
sendMessage({String?
text, List<Map<String, Object>>?
payload})
Sends a message to the conversation.
Sending messages is available only for participants that have write permissions (VIConversationParticipant.canWrite is true).
Other parties of the conversation (online participants and logged in clients) can be informed about sending messages to the conversation via the VIMessenger.onSendMessage callback.
To be informed about sending messages while being offline, participants can subscribe to the onSendMessage messenger push notification.
Throws VIException, if operation failed, otherwise returns VIMessageEvent instance. For all possible errors see VIMessagingError
Parameters
text:
String?
OptionalMessage text, maximum 5000 characters
payload:
List<Map<String, Object>>?
OptionalMessage payload
Returns
type:
Future<VIMessageEvent>
typing
Future<VIConversationServiceEvent>
typing()
Informs the cloud that the user is typing some text.
The method calls within 10s interval from the last call cause VIException.
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'.
Other parties of the conversation (online participants and logged in clients) can be informed about typing via the VIMessenger.onTyping callback.
Throws VIException, if operation failed, otherwise returns VIConversationServiceEvent instance. For all possible errors see VIMessagingError
Returns
type:
Future<VIConversationServiceEvent>
update
Future<VIConversationEvent>
update()
Sends the conversation changes to the cloud. The sent changes are: title, public join flag and custom data.
Successful update happens if a participant is the owner (VIConversationParticipant.isOwner is true).
Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError
Returns
type:
Future<VIConversationEvent>
Props
createdTime
int
createdTime
UNIX timestamp (seconds) that specifies the time of the conversation creation.
Returns
type:
int
customData
Map<String, dynamic>
customData
Custom data, up to 5kb.
Returns
type:
Map<String, dynamic>
direct
bool
direct
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 VIMessenger.createConversation the method returns the UUID of the already existing direct conversation.
Returns
type:
bool
lastSequence
int
lastSequence
Sequence of the last event in the conversation.
Returns
type:
int
lastUpdateTime
int
lastUpdateTime
UNIX timestamp (seconds) that specifies the time when one of VIConversationEvent or VIMessageEvent is the last triggered event in this conversation.
Returns
type:
int
participants
participants
List of participants alongside with their permissions.
Returns
type:
publicJoin
bool
publicJoin
Whether the conversation is public.
If true, anyone can join the conversation by UUID.
A public conversation cannot be direct.
Note that changing this property value does not send changes to the cloud. Use VIConversation.update to send all changes at once
Returns
type:
bool
title
String?
title
Current conversation title.
Note that changing this property value does not send changes to the cloud. Use VIConversation.update to send all changes at once
Returns
type:
String?
uber
bool
uber
Whether the conversation is uber.
A uber conversation cannot be direct.
Users in a uber conversation cannot retrieve messages that have been posted to the conversation after they quit.
Returns
type:
bool
uuid
String
uuid
An universally unique identifier (UUID) of this conversation.
Returns
type:
String