MessagingProviderHelper

class MessagingProviderHelper

Helper class that provides all common functionality that is needed by messaging providers.

For example a messaging provider service can be initialized like this:

class StockSmsService(
iviServiceHostContext: IviServiceHostContext,
serviceIdProvider: IviDiscoverableServiceIdProvider
) : MessagingProviderServiceBase(iviServiceHostContext, serviceIdProvider) {
// ...

private val messagingProviderHelper = MessagingProviderHelper().also {
conversationsForProvider = it.conversations
messageTypesForProvider = it.messageTypes
it.registerSendMessageCallback { conversation, message ->
sendMessage(conversation, message)
}
}

// ...
}

Constructors

Link copied to clipboard
fun MessagingProviderHelper()

Properties

Link copied to clipboard
val conversations: MirrorableMap<Uid<Conversation>, Conversation>

The conversations.

Link copied to clipboard
val messageTypes: MirrorableMap<MessageType, Boolean>

The message types supported by the provider.

Functions

Link copied to clipboard
fun addOrUpdateAllConversations(conversations: Map<Uid<Conversation>, Conversation>)

Adds or updates the specified conversations.

Link copied to clipboard
fun addOrUpdateAllMessages(messages: Collection<Message>)

Adds or updates all the specified messages.

Link copied to clipboard
fun addOrUpdateConversation(conversation: Conversation)

Adds or updates the specified conversation. Note that Conversation.unreadMessages will be ignored. Messages can only be added by using addOrUpdateMessage.

Link copied to clipboard
fun addOrUpdateMessage(message: Message): Boolean

Adds or updates the specified message.

Link copied to clipboard
fun findConversation(    contacts: Set<ConversationContact>,     messageType: MessageType,     source: ConversationSource?): Conversation?

Finds a conversation originating from the source that has the specified contacts and the specified messageType. If source is null, the source field is ignored.

Link copied to clipboard
fun findMessageById(messageId: Uid<Message>): Message?

Finds the message with the specified messageId in all conversations.

Link copied to clipboard
fun findOrCreateConversation(    contacts: Set<ConversationContact>,     messageType: MessageType,     source: ConversationSource?,     applicationDisplayName: StringResolver,     conversationCapabilities: EnumSet<ConversationCapability>): Conversation

Finds a conversation originating from the source that has the specified contacts and the specified messageType. Otherwise, creates and adds a new conversation with the specified parameters.

Link copied to clipboard
fun markConversationReadUpToAndIncluding(conversationId: Uid<Conversation>, messageId: Uid<Message>): Boolean

Marks all messages up to and including the message with the specified messageId as read for the conversation with the specified conversationId.

Link copied to clipboard
fun registerSendMessageCallback(callback: SendMessageCallback): SendMessageCallback?

Registers the specified callback to be called when a message is added with the MessageState.OUTGOING_QUEUED state. This will replace a previously registered callback.

Link copied to clipboard
fun removeAllMessages(conversationId: Uid<Conversation>, messageIds: Collection<Uid<Message>>)

Removes all messages with specified messageIds from the conversation with the specified conversationId.

Link copied to clipboard
fun removeConversation(conversationId: Uid<Conversation>): Conversation?

Removes the conversation with the specified conversationId.

Link copied to clipboard
fun retainAllConversations(conversationIds: Collection<Uid<Conversation>>)

Retains only the conversations with the specified conversationIds. Removes the remaining conversations.

Link copied to clipboard
fun retainAllMessages(messageIds: Collection<Uid<Message>>)

Retains only the messages with the specified messageIds. Removes the remaining messages.

Link copied to clipboard
fun setMessageTypeEnabled(messageType: MessageType, enabled: Boolean)

Enables or disables the specified messageType according to the specified enabled parameter.