Skip to content

Commit 353ef32

Browse files
committed
chore(android-core): update chat docs with v2 changes
1 parent 7455df6 commit 353ef32

File tree

3 files changed

+45
-11
lines changed

3 files changed

+45
-11
lines changed

docs/android-core/chat/introduction.mdx

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Introducing chat
2+
title: Introduction
33
description: >-
44
Learn the basics of integrating Dyte's chat functionality into your Android
55
application – a step towards immersive real-time communication.
@@ -29,7 +29,8 @@ class DyteTextMessage(
2929
pluginId: String?,
3030
val message: String,
3131
time: String,
32-
channelId: String? = null,
32+
createdAtMillis: Long,
33+
targetUserIds: List<String>?,
3334
)
3435
```
3536

@@ -43,7 +44,8 @@ class DyteImageMessage(
4344
pluginId: String?,
4445
val link: String,
4546
time: String,
46-
channelId: String? = null,
47+
createdAtMillis: Long,
48+
targetUserIds: List<String>?,
4749
)
4850
```
4951

@@ -57,9 +59,10 @@ class DyteFileMessage(
5759
pluginId: String?,
5860
val name: String,
5961
time: String,
62+
createdAtMillis: Long,
6063
val link: String,
6164
val size: Long,
62-
channelId: String? = null,
65+
targetUserIds: List<String>?,
6366
)
6467
```
6568

docs/android-core/chat/receiving-chat-messages.mdx

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,25 @@ subscribe to this events by calling
2020
meeting.addChatEventsListener(object :
2121
DyteChatEventsListener {
2222
override fun onChatUpdates(messages: List<DyteChatMessage>) {
23-
// to load chat messages
23+
// to load chat messages
2424
}
2525

2626
override fun onNewChatMessage(message: DyteChatMessage) {
2727
// when a new chat message is shared in the meeting
2828
}
29+
30+
override fun onMessageRateLimitReset() {
31+
// when the rate limit for sending messages of self is reset
32+
}
2933
})
3034
```
3135

3236
The `onChatUpdates()` method will be called whenever there is a change in the chat messages. The `messages` parameter is a list of `DyteChatMessage` objects that have been sent in the chat.
3337

3438
The `onNewChatMessage()` method will be called whenever a new chat message is shared in the meeting. The `message` parameter is a `DyteChatMessage` object that has been sent in the chat.
3539

40+
The `onMessageRateLimitReset()` method will be called when the rate limit for sending messages of self is reset and you can send messages again.
41+
3642
<head>
3743
<title>Android Core Receiving chat</title>
3844
</head>

docs/android-core/chat/sending-a-chat-message.mdx

+31-6
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,44 @@ You can send an image with the help of `meeting.chat.sendImageMessage()` and
2828
sends it to the participants in the meeting.
2929

3030
```kotlin
31-
val filePath = "file_path_of_image"
32-
val fileName = "file_name"
33-
meeting.chat.sendImageMessage(filePath, fileName)
31+
meeting.chat.sendImageMessage(fileUri) { err ->
32+
// Handle error if any
33+
}
3434
```
3535

3636
## Send a file
3737

3838
Sending a file is quite similar to sending an image. The only difference is that when you send an image, a preview will be shown in the meeting chat, which is not the case for sending files. That being said, an image can be sent as a file too using `meeting.chat.sendFileMessage()`.
3939

4040
```kotlin
41-
val filePath = "file_path_of_image"
42-
val fileName = "file_name"
43-
meeting.chat.sendFileMessage(filePath, fileName)
41+
meeting.chat.sendFileMessage(fileUri) { err ->
42+
// Handle error if any
43+
}
44+
```
45+
46+
## Error types
47+
48+
Both `sendImageMessage` and `sendFileMessage` methods accept a callback function that will be called with an error object if there is an error while sending the message.
49+
50+
The error object is of type `ChatFileError`, which can be classified into the following:
51+
52+
- FileFormatNotAllowed
53+
- PermissionDenied
54+
- RateLimitBreached
55+
- ReadFailed
56+
- UploadFailed
57+
58+
A `when` block can be used to handle these errors inside the callback, as shown below:
59+
60+
```kotlin
61+
when (err) {
62+
is ChatFileError.FileFormatNotAllowed -> {}
63+
is ChatFileError.PermissionDenied -> {}
64+
is ChatFileError.RateLimitBreached -> {}
65+
is ChatFileError.ReadFailed -> {}
66+
is ChatFileError.UploadFailed -> {}
67+
else -> {}
68+
}
4469
```
4570

4671
<head>

0 commit comments

Comments
 (0)