Skip to content

Commit

Permalink
feat: flutter-core docs in place
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitkhirid authored and palashgo committed Dec 12, 2022
1 parent 4f3c11d commit f37f992
Show file tree
Hide file tree
Showing 22 changed files with 833 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/flutter-core/chat/_category_.json
@@ -0,0 +1,5 @@
{
"position": 6,
"label": "Chat",
"collapsible": true
}
57 changes: 57 additions & 0 deletions docs/flutter-core/chat/introduction.mdx
@@ -0,0 +1,57 @@
---
title: Introducing chat
description: Send and receive chat messages in a meeting.
sidebar_position: 1
tags: [mobile-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.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 `DyteChatMessage`.

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

```kotlin
sealed class DyteChatMessage(
val userId: String,
val displayName: String,
val read: Boolean,
val pluginId: String?,
val type: DyteMessageType
) {
class DyteTextMessage(
userId: String,
displayName: String,
read: Boolean,
pluginId: String?,
val message: String
) : DyteChatMessage(userId, displayName, read, pluginId, TEXT)

class ImageMessage(
userId: String,
displayName: String,
read: Boolean,
pluginId: String?,
val link: String,
val fileUri: String?,
val fileName: String?
) : DyteChatMessage(userId, displayName, read, pluginId, IMAGE)

class FileMessage(
userId: String,
displayName: String,
read: Boolean,
pluginId: String?,
val name: String,
val fileUri: String?,
) : DyteChatMessage(userId, displayName, read, pluginId, FILE)
}

enum class DyteMessageType {
TEXT,
IMAGE,
FILE;
}
```
28 changes: 28 additions & 0 deletions docs/flutter-core/chat/receiving-chat-messages.mdx
@@ -0,0 +1,28 @@
---
title: Receiving chat messages
description: Receive chat messages that has been sent in a meeting.
sidebar_position: 3
tags: [mobile-core, chat]
---

# Receiving chat messages

To be able to receive chat messages you need to implement a method `onChatUpdates()` method from callback `DyteMeetingRoomEventsListener`. You can subscribe to this events by calling `meeting.addMeetingEventsListener(dyteMeetingRoomEventsListener)`

```kotlin
meeting.addMeetingRoomEventsListener(object :
DyteMeetingRoomEventsListener {
override fun onChatUpdates(
newMessage: Boolean,
message: DyteChatMessage?,
messages: List<DyteChatMessage>
) {
super.onChatUpdates(newMessage, message, messages)
// your code to handle new chat message
}
})
```

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

When a chat message is received, the `meeting.chat.messages` list is also updated.
39 changes: 39 additions & 0 deletions docs/flutter-core/chat/sending-a-chat-message.mdx
@@ -0,0 +1,39 @@
---
title: Sending a chat message
description: Send a chat message in a meeting.
sidebar_position: 2
tags: [mobile-core, chat]
---

# Sending a chat message

As mentioned in [introduction](./introduction), there are 3 types of chat messages - text messages, images, and files. There is a method in `meeting.chat` to send a message of each type.

## Send a text message

To send a text message, the `meeting.chat.sendTextMessage()` method can be used. This accepts a string `message` and sends it to the room.

```kotlin
val message = "Is this the real life?"
meeting.chat.sendTextMessage(message)
```

## Send an image

You can send an image with the help of `meeting.chat.sendImageMessage()` and sends it to the participants in the meeting.

```kotlin
val filePath = "file_path_of_image"
val fileName = "file_name"
meeting.chat.sendImageMessage(filePath, fileName)
```

## Send a file

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()`.

```kotlin
val filePath = "file_path_of_image"
val fileName = "file_name"
meeting.chat.sendFileMessage(filePath, fileName)
```
63 changes: 63 additions & 0 deletions docs/flutter-core/installation.mdx
@@ -0,0 +1,63 @@
---
title: Installation
description: Installation for android core.
sidebar_position: 1
tags: [flutter-core, installation]
slug: /
---

# Installation

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Install the SDK using maven dependency.

```shell
implementation 'io.dyte:core-android:{latest-version}'
```

:::info

The below instructions are for the release builds, debug builds should work without any additional steps.

:::

1. Create / append to the file `android/app/proguard-rules.pro`

```groovy
# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
static <1>$Companion Companion;
}
# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
static **$* *;
}
-keepclassmembers class <2>$<3> {
kotlinx.serialization.KSerializer serializer(...);
}
# keep webrtc classes
-keep class org.webrtc.** { *; }
-dontwarn org.chromium.build.BuildHooksAndroid
# keep ktor classes
-keep class io.ktor.** { *; }
```

2. In your `android/app/build.gradle` edit the release configuration and add the following line importing the proguard configuration

```groovy
buildTypes {
release {
...
...
...
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
```
5 changes: 5 additions & 0 deletions docs/flutter-core/local-user/_category_.json
@@ -0,0 +1,5 @@
{
"position": 3,
"label": "Local User",
"collapsible": true
}
56 changes: 56 additions & 0 deletions docs/flutter-core/local-user/events.mdx
@@ -0,0 +1,56 @@
---
title: Events
description: Local user events guide.
sidebar_position: 2
tags: [mobile-core, local-user, self]
---


# Local User - Events

You can subscribe to various events on the local user by implementing `DyteSelfEventsListener` and passing the object to `meeting.addSelfEventsListener(dyteSelfEventsListener)`.

### Room joined

Triggered when the room join event completes and now the meeting is ready to produce and consume media.

```kotlin
meeting.addSelfEventsListener(object : DyteSelfEventsListener {
override fun onRoomJoined() {
super.onRoomJoined()
}
});
```
### Video update

Triggered when the user starts / stops the video using `enableVideo` or `disableVideo`

```kotlin
meeting.addSelfEventsListener(object : DyteSelfEventsListener {
override fun onVideoUpdate(videoEnabled: Boolean) {
super.onVideoUpdate(videoEnabled)
if (videoEnabled) {
// video is enabled, and other participants in room can see local user
} else {
// video is disabled, and other participants in room can not see local user.
}
}
});
```

### Audio update

Triggered when the user starts / stops the audio using `enableAudio` or `disableAudio`

```kotlin
meeting.addSelfEventsListener(object : DyteSelfEventsListener {
override fun onAudioUpdate(audioEnabled: Boolean) {
super.onAudioUpdate(videoEnabled)
if (audioEnabled) {
// audio is enabled, and other participants in room can hear local user
} else {
// audio is disabled, and other participants in room can not hear local user.
}
}
});
```
88 changes: 88 additions & 0 deletions docs/flutter-core/local-user/introduction.mdx
@@ -0,0 +1,88 @@
---
title: Introduction
description: Local user setup guide.
sidebar_position: 1
tags: [mobile-core, local-user, self]
---

# Introduction - Local User

The local user has the methods and properties on the local user media controls. Accessible via `localUser` within the `meeting` object.

## Properties

Here is a list of properties that local user provides:

- `id`: The ID of the participant pertaining to local user.
- `name`: Contains Name of the local user.
- `clientSpecificId`: Identifier provided by the developer while adding the participant.
- `audioTrack`: The audio track for the local user.
- `videoTrack`: The video track for the local user.
- `screenShareTracks`: The screen share video and audio tracks for the local user.
- `audioEnabled`: A boolean value indicating if the audio currently enabled.
- `videoEnabled`: A boolean value indicating if the video currently enabled.

## Change default audio / video settings

By default as soon as you join the meeting the SDK will produce your video and audio streams.
To change this behaviour use the `audioEnabled` & `videoEnabled` parameter

```kotlin {5,6}
val meetingInfo = DyteMeetingInfo(
orgId = ORGNIZATION_ID,
roomName = MEETING_ROOM_NAME,
authToken = AUTH_TOKEN,
audioEnabled = false,
videoEnabled = true
)
```

## Turn audio/video tracks after joining the room

If audio and video tracks are disabled during the `DyteMobileClient` initialization process. You can setup the audio and video tracks by simply calling `enableAudio()` and `enableVideo()` like below:

```kotlin
meeting.localUser.enableAudio()
meeting.localUser.enableVideo()
```

## Change the name of the local user

Change the user's name by calling `setDisplayName` method. The changed name will reflect across all participants ONLY if the change happens before joining the meeting.

```kotlin
meeting.localUser.setDisplayName("New Name")
```

## Mute/Unmute microphone

```kotlin
// Mute Audio
meeting.localUser.disableAudio()

// Unmute Audio
meeting.localUser.enableAudio()

// Get current status
meeting.localUser.audioEnabled
```

## Enable/Disable camera

```kotlin
// Disable Video
meeting.localUser.disableVideo()

// Enable Video
meeting.localUser.enableVideo()

// Get current status
meeting.localUser.videoEnabled
```

## Switch camera between primary and secondary

```kotlin
// switch camera
meeting.localUser.switchCamera()
```
27 changes: 27 additions & 0 deletions docs/flutter-core/local-user/manage-media-devices.mdx
@@ -0,0 +1,27 @@
---
title: Manage Media Devices
description: Local user media guide to manage media permissions.
sidebar_position: 3
tags: [web-core, local-user, self, self events]
---

# Manage Media Devices

Media devices represents the hardwar for the camera, microphone and speaker devices.
To get the list of media devices that are currently being used, you can use the following methods:

```kotlin
// Get all audio devices
val audioDevices = meeting.self.getAudioDevices();

// Get all video devices
val videoDevices = meeting.self.getVideoDevices();
```

## Set device

To set a device as an active device, you can call `setDevice` method. This takes a `MediaDeviceInfo` object, and replaces the same `kind` device.

```kotlin
meeting.self.setDevice(device);
```
5 changes: 5 additions & 0 deletions docs/flutter-core/participants/_category_.json
@@ -0,0 +1,5 @@
{
"position": 5,
"label": "Participants",
"collapsible": true
}

0 comments on commit f37f992

Please sign in to comment.