# Chat

class Chat

A chat instance.

This class allows performing actions over this specific chat like deleting the chat, sending a message or get the message history list

## Properties

currentMessages
Link copied to clipboard
val currentMessages: List<XMPPMessage>
currentStatus
Link copied to clipboard
val currentStatus: ChatState?
lastMessage
Link copied to clipboard
val lastMessage: XMPPMessage?
participants
Link copied to clipboard
val participants: List<ChatContact>
rx
Link copied to clipboard
val rx: ChatRx

Access to the reactive API of the chat.

title
Link copied to clipboard
val title: String
type
Link copied to clipboard
val type: ChatType
unreadMessages
Link copied to clipboard
val unreadMessages: Int
xmppJid
Link copied to clipboard
val xmppJid: XmppJid

## Functions

addListener
Link copied to clipboard
fun addListener(listener: ChatListener)

Adds a listener to receive chat events.

archive
Link copied to clipboard
fun archive(onCompletion: (SippoResourceError?) -> Unit)

Archives a one to one chat.

delete
Link copied to clipboard
fun delete(onCompletion: (SippoResourceError?) -> Unit)

Removes a MUC chat.

equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
fetchLastMessages
Link copied to clipboard
fun fetchLastMessages(onCompletion: (Either<List<XMPPMessage>, SippoResourceError>) -> Unit)

Retrieves the last messages available to the current chat. The maximum number of messages to be obtained from the server if available is 15.

fetchMessagesBy
Link copied to clipboard
fun fetchMessagesBy(query: MessageQuery, onCompletion: (Either<List<XMPPMessage>, SippoResourceError>) -> Unit)

Retrieves the messages available to the current chat within the specified query.

hashCode
Link copied to clipboard
open override fun hashCode(): Int
invite
Link copied to clipboard
fun invite(userId: String, onCompletion: (SippoResourceError?) -> Unit)

Adds a new participant to the current chat.

fun invite(userIds: List<String>, onCompletion: (SippoResourceError?) -> Unit)

Adds a list of participants to the current chat.

join
Link copied to clipboard
fun join(onCompletion: (SippoResourceError?) -> Unit)

Sends a special message asking the recipient to join the room associated to the current chat. This method has no effect for individual chats.

kick
Link copied to clipboard
fun kick(userId: String, onCompletion: (SippoResourceError?) -> Unit)

Removes a participant from the current chat.

markAsDisplayed
Link copied to clipboard
fun markAsDisplayed(onCompletion: (SippoResourceError?) -> Unit)

Marks all messages as viewed since the last message received.

removeListener
Link copied to clipboard
fun removeListener(listener: ChatListener)

Removes the specified listener.

sendFile
Link copied to clipboard
fun sendFile(file: File, onCompletion: (SippoResourceError?) -> Unit)

Uploads the file and sends its URI as a message to this chat.

sendFileProgress
Link copied to clipboard
fun sendFileProgress(file: File, listener: FileUploadListener)

Uploads the file and sends its URI as a message to this chat.

sendMessage
Link copied to clipboard
fun sendMessage(message: String, onCompletion: (SippoResourceError?) -> Unit)

Sends a text message to this chat.

setState
Link copied to clipboard
fun setState(query: XMPPChatStateQuery, onCompletion: (SippoResourceError?) -> Unit)

Sets the current state of current chat instance. This method will send an empty Message with the state attached.