Rate this page:

VIConversation

Interface that may be used to manage a conversation.

Methods

addParticipants

Copy URL

Future<VIConversationEvent>

addParticipants(

List<VIConversationParticipant>

participants
)

Add new participants to the conversation.

It's 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. Will cause 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

Returns

editParticipants

Copy URL

Future<VIConversationEvent>

editParticipants(

List<VIConversationParticipant>

participants
)

Edit participants permissions. It's possible only if the current user can manage other participants (VIConversationParticipant.canManageParticipants is true).

Duplicated users are ignored. Will cause 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

Returns

markAsRead

Copy URL

Future<VIConversationServiceEvent>

markAsRead(

int

sequence
)

Mark 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 will mark 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. Shouldn't be greater than currently possible.

Returns

removeParticipants

Copy URL

Future<VIConversationEvent>

removeParticipants(

List<VIConversationParticipant>

participants
)

Remove participants from the conversation.

It's possible only on two conditions:

Duplicated users are ignored. Will cause 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

Returns

retransmitEvents

Copy URL

Future<VIRetransmitEvent>

retransmitEvents(

int

from,

int

to
)

Request 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 can't 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 amount of retransmitted events per method call is 100. Requesting more than 100 events will cause VIException.

If the current user quits a VIConversation.uber conversation, messages that are posted during the user's absence will not be 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

retransmitEventsFrom

Copy URL

Future<VIRetransmitEvent>

retransmitEventsFrom(

int

from,

int

count
)

Request 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 can't 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 amount of retransmitted events per method call is 100. Requesting more than 100 events will cause VIException.

If the current user quits a VIConversation.uber conversation, messages that are posted during the user's absence will not be 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

retransmitEventsTo

Copy URL

Future<VIRetransmitEvent>

retransmitEventsTo(

int

to,

int

count
)

Request 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 can't 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 amount of retransmitted events per method call is 100. Requesting more than 100 events will cause VIException.

If the current user quits a VIConversation.uber conversation, messages that are posted during the user's absence will not be 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

sendMessage

Copy URL

Future<VIMessageEvent>

sendMessage({

String

text,

List<Map<String, Object>>

payload
}
)

Send 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

    Optional

    Message text, maximum 5000 characters

  • payload:

    List<Map<String, Object>>

    Optional

    Message payload

Returns

typing

Copy URL

Future<VIConversationServiceEvent>

typing()

Inform 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 will mark 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

update

Copy URL

Future<VIConversationEvent>

update()

Send conversation changes to the cloud. The sent changes are: title, public join flag and custom data.

Successful update will happen 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

Props

createdTime

Copy URL

int

createdTime

The UNIX timestamp (seconds) that specifies the time of the conversation creation.

Returns

  • type:

    int

customData

Copy URL

Map<String, dynamic>

customData

A custom data, up to 5kb.

Returns

  • type:

    Map<String, dynamic>

direct

Copy URL

bool

direct

A bool value that determines whether the conversation is direct.

A direct conversation can't 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 can't 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 will return the UUID of the already existing direct conversation.

Returns

  • type:

    bool

lastSequence

Copy URL

int

lastSequence

The sequence of the last event in the conversation.

Returns

  • type:

    int

lastUpdateTime

Copy URL

int

lastUpdateTime

The UNIX timestamp (seconds) that specifies the time when one of VIConversationEvent or VIMessageEvent was the last provoked event in this conversation.

Returns

  • type:

    int

participants

Copy URL

List<VIConversationParticipant>

participants

A list of participants alongside with their permissions.

Returns

publicJoin

Copy URL

bool

publicJoin

A bool value that determines whether the conversation is public.

If true, anyone can join the conversation by UUID.

A public conversation can't 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

Copy URL

String

title

The 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

Copy URL

bool

uber

A bool value that determines whether the conversation is uber.

A uber conversation can't be direct.

Users in a uber conversation will not be able to retrieve messages that were posted to the conversation after they quit.

Returns

  • type:

    bool

uuid

Copy URL

String

uuid

An universally unique identifier (UUID) of this conversation.

Returns

  • type:

    String