Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): add core docs for chat and polls #351

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 0 additions & 92 deletions docs/android-core-new/chat/edit-chat-messages.mdx

This file was deleted.

94 changes: 53 additions & 41 deletions docs/android-core-new/chat/introduction.mdx
Original file line number Diff line number Diff line change
@@ -1,55 +1,67 @@
---
title: Introducing chat
description: Send and receive chat messages in a meeting.
description: >-
Learn the basics of integrating Dyte's chat functionality into your Android
application – a step towards immersive real-time communication.
sidebar_position: 1
tags:
- web-core
- android-core
- chat
---

# Introducing chat

The meeting chat object is stored in `meeting.chat`, which has methods for
sending and receiving messages. There are 3 types of messages that can be sent
in chat - text messages, images, and files.
The meeting chat object is stored in `meeting.chat`, which has methods for sending and receiving messages. There are 3 types of messages that can be sent in chat - text messages, images, and files.

The `meeting.chat.messages` array contains all the messages that have been sent
in the chat. This is an array of objects, where each object is of type
`Message`.

The type `Message` is defined in the following manner.

```ts
interface BaseMessage<T extends MessageType> {
type: T;
userId: string;
displayName: string;
time: Date;
id: string;
isEdited?: boolean;
read?: boolean;
pluginId?: string;
pinned?: boolean;
targetUserIds?: string[];
}

interface TextMessage extends BaseMessage<MessageType.text> {
message: string;
}

interface ImageMessage extends BaseMessage<MessageType.image> {
link: string;
}

interface FileMessage extends BaseMessage<MessageType.file> {
name: string;
size: number;
link: string;
}

type Message = TextMessage | ImageMessage | FileMessage;
`DyteChatMessage`.

We support three types of chat messages, they are as follows

- Text Message

```kotlin
class DyteTextMessage(
userId: String,
displayName: String,
read: Boolean,
pluginId: String?,
val message: String,
time: String,
channelId: String? = null,
)
```

- Image Message

```kotlin
class DyteImageMessage(
userId: String,
displayName: String,
read: Boolean,
pluginId: String?,
val link: String,
time: String,
channelId: String? = null,
)
```

- File Message

```kotlin
class DyteFileMessage(
userId: String,
displayName: String,
read: Boolean,
pluginId: String?,
val name: String,
time: String,
val link: String,
val size: Long,
channelId: String? = null,
)
```

<head>
<title>Web Core Introducing chat</title>
</head>
All above objects are of type `DyteChatMessage` along with their own class
variables.
100 changes: 0 additions & 100 deletions docs/android-core-new/chat/other-chat-functions.mdx

This file was deleted.

47 changes: 21 additions & 26 deletions docs/android-core-new/chat/receiving-chat-messages.mdx
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
---
title: Receiving chat messages
description: Receive chat messages that have been sent in a meeting.
description: >-
"Discover how to implement the functionality to receive chat messages in your
Android app using Dyte
sidebar_position: 3
tags:
- web-core
- android-core
- chat
---

# Receiving chat messages

The `meeting.chat` object emits events when new chat messages are received. You
can listen for the `chatUpdate` event to log when a new chat message is
received.
To be able to receive chat messages you need to implement a method
`onChatUpdates()` method from callback `DyteChatEventsListener`. You can
subscribe to this events by calling
`meeting.addChatEventsListener(dyteChatEventsListener)`

```ts
meeting.chat.on('chatUpdate', ({ message, messages }) => {
console.log(`Received message ${message}`);
console.log(`All messages in chat: ${messages.join(', ')}`);
});
```

Here, the `message` is of type `Message`, as defined in
[introduction](./introduction). `messages` is a list of all chat messages in the
meeting, which is the same as `meeting.chat.messages`.
```kotlin
meeting.addChatEventsListener(object :
DyteChatEventsListener {
override fun onChatUpdates(messages: List<DyteChatMessage>) {
// to load chat messages
}

When a chat message is received, the `meeting.chat.messages` list is also
updated.

```ts
console.log(JSON.stringify(meeting.chat.messages));
meeting.chat.on('chatUpdate', () => {
console.log(JSON.stringify(meeting.chat.messages));
});
override fun onNewChatMessage(message: DyteChatMessage) {
// when a new chat message is shared in the meeting
}
})
```

<head>
<title>Web Core Receiving chat messages</title>
</head>
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.

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.
Loading
Loading