Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.

Commit 38f60f1

Browse files
authored
Merge pull request #237 from RocketChat/new/video-call-support
[NEW] Video conference
2 parents 54676f5 + b74e73e commit 38f60f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+403
-542
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ buildscript {
99

1010
dependencies {
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
12-
classpath "gradle.plugin.org.jmailen.gradle:kotlinter-gradle:${versions.kotlinter}"
12+
classpath "org.jmailen.gradle:kotlinter-gradle:${versions.kotlinter}"
1313
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}"
1414
}
1515
}

compat/build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ compileTestKotlin {
3636
kotlinOptions.jvmTarget = "1.8"
3737
}
3838

39-
kotlin {
40-
experimental {
41-
coroutines "enable"
42-
}
43-
}
44-
4539
dokka {
4640
outputFormat = 'html'
4741
outputDirectory = "$buildDir/javadoc"

compat/src/main/kotlin/chat/rocket/core/compat/Call.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package chat.rocket.core.compat
22

3-
import kotlinx.coroutines.experimental.Job
3+
import kotlinx.coroutines.Job
44

55
class Call(val job: Job) {
66
fun cancel() {

compat/src/main/kotlin/chat/rocket/core/compat/Server.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import chat.rocket.common.model.ServerInfo
44
import chat.rocket.core.RocketChatClient
55
import chat.rocket.core.compat.internal.callback
66
import chat.rocket.core.internal.rest.serverInfo
7-
import kotlinx.coroutines.experimental.CommonPool
7+
import kotlinx.coroutines.Dispatchers
88

9-
fun RocketChatClient.serverInfo(future: Callback<ServerInfo>): Call =
10-
callback(CommonPool, future) {
11-
serverInfo()
12-
}
9+
/**
10+
* Returns the current logged server information.
11+
* Must be used with a coroutine context (async, launch, etc)
12+
*/
13+
fun RocketChatClient.serverInfo(future: Callback<ServerInfo>): Call = callback(Dispatchers.IO, future) { serverInfo() }

compat/src/main/kotlin/chat/rocket/core/compat/User.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@ import chat.rocket.core.RocketChatClient
44
import chat.rocket.core.compat.internal.callback
55
import chat.rocket.core.internal.rest.me
66
import chat.rocket.core.model.Myself
7-
import kotlinx.coroutines.experimental.CommonPool
7+
import kotlinx.coroutines.Dispatchers
88

99
/**
1010
* Returns the current logged user information, useful to check if the Token from TokenProvider
1111
* is still valid. Must be used with a coroutine context (async, launch, etc)
12-
*
13-
* @return Call
14-
* @see
15-
* @see RocketChatException
1612
*/
17-
fun RocketChatClient.me(future: Callback<Myself>): Call =
18-
callback(CommonPool, future) {
19-
me()
20-
}
13+
fun RocketChatClient.me(future: Callback<Myself>): Call = callback(Dispatchers.IO, future) { me() }

compat/src/main/kotlin/chat/rocket/core/compat/internal/Callback.kt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,35 @@ package chat.rocket.core.compat.internal
33
import chat.rocket.common.RocketChatException
44
import chat.rocket.core.compat.Call
55
import chat.rocket.core.compat.Callback
6-
import kotlinx.coroutines.experimental.AbstractCoroutine
7-
import kotlinx.coroutines.experimental.CoroutineScope
8-
import kotlinx.coroutines.experimental.DefaultDispatcher
9-
import kotlinx.coroutines.experimental.Job
10-
import kotlinx.coroutines.experimental.newCoroutineContext
11-
import kotlin.coroutines.experimental.CoroutineContext
12-
import kotlin.coroutines.experimental.startCoroutine
6+
import kotlinx.coroutines.AbstractCoroutine
7+
import kotlinx.coroutines.CoroutineScope
8+
import kotlinx.coroutines.Dispatchers
9+
import kotlinx.coroutines.GlobalScope
10+
import kotlinx.coroutines.InternalCoroutinesApi
11+
import kotlinx.coroutines.Job
12+
import kotlinx.coroutines.newCoroutineContext
13+
import kotlin.coroutines.CoroutineContext
14+
import kotlin.coroutines.startCoroutine
1315

1416
@JvmOverloads
1517
fun <T> callback(
16-
context: CoroutineContext = DefaultDispatcher,
18+
context: CoroutineContext = Dispatchers.Default,
1719
callback: Callback<T>,
1820
block: suspend CoroutineScope.() -> T
1921
): Call {
20-
val newContext = newCoroutineContext(context)
22+
val newContext = GlobalScope.newCoroutineContext(context)
2123
val job = Job(newContext[Job])
2224
val coroutine = CallbackCoroutine(newContext + job, callback)
2325
block.startCoroutine(coroutine, coroutine)
2426
return Call(job)
2527
}
2628

29+
@UseExperimental(InternalCoroutinesApi::class)
2730
private class CallbackCoroutine<in T>(
2831
parentContext: CoroutineContext,
2932
private val callback: Callback<T>
3033
) : AbstractCoroutine<T>(parentContext, true) {
34+
3135
override fun onCompleted(value: T) {
3236
callback.onSuccess(value)
3337
}

core/build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ compileTestKotlin {
4141
kotlinOptions.jvmTarget = "1.8"
4242
}
4343

44-
kotlin {
45-
experimental {
46-
coroutines "enable"
47-
}
48-
}
49-
5044
dokka {
5145
outputFormat = 'html'
5246
outputDirectory = "$buildDir/javadoc"

core/src/main/kotlin/chat/rocket/core/RocketChatClient.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,25 @@ import chat.rocket.core.model.Myself
2727
import chat.rocket.core.model.Room
2828
import chat.rocket.core.model.url.MetaJsonAdapter
2929
import com.squareup.moshi.Moshi
30-
import kotlinx.coroutines.experimental.channels.Channel
30+
import kotlinx.coroutines.CoroutineScope
31+
import kotlinx.coroutines.Dispatchers
32+
import kotlinx.coroutines.channels.Channel
3133
import okhttp3.HttpUrl
3234
import okhttp3.MediaType
3335
import okhttp3.OkHttpClient
3436
import java.security.InvalidParameterException
37+
import kotlin.coroutines.CoroutineContext
3538

3639
class RocketChatClient private constructor(
3740
internal val httpClient: OkHttpClient,
3841
baseUrl: String,
3942
userAgent: String,
4043
internal val tokenRepository: TokenRepository,
4144
internal val logger: Logger
42-
) {
45+
) : CoroutineScope {
46+
override val coroutineContext: CoroutineContext
47+
get() = Dispatchers.Default
48+
4349
internal val moshi: Moshi = Moshi.Builder()
4450
.add(FallbackSealedClassJsonAdapter.ADAPTER_FACTORY)
4551
.add(RestResult.JsonAdapterFactory())

core/src/main/kotlin/chat/rocket/core/internal/AttachmentAdapter.kt

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,34 @@ class AttachmentAdapter(moshi: Moshi, private val logger: Logger) : JsonAdapter<
2424
private val actionAdapter = moshi.adapter<ButtonAction>(ButtonAction::class.java)
2525

2626
private val NAMES = arrayOf(
27-
"title", // 0
28-
"type", // 1
29-
"description", // 2
30-
"author_name", // 3
31-
"text", // 4
32-
"thumb_url", // 5
33-
"color", // 6
34-
"title_link", // 7
35-
"title_link_download", // 8
36-
"image_url", // 9
37-
"image_type", // 10
38-
"image_size", // 11
39-
"video_url", // 12
40-
"video_type", // 13
41-
"video_size", // 14
42-
"audio_url", // 15
43-
"audio_type", // 16
44-
"audio_size", // 17
45-
"message_link", // 18
46-
"attachments", // 19
47-
"ts", // 20
48-
"author_icon", // 21
49-
"author_link", // 22
50-
"image_preview", // 23
51-
"fields", // 24
52-
"fallback", // 25
53-
"button_alignment", // 26
54-
"actions" // 27
27+
"title", // 0
28+
"type", // 1
29+
"description", // 2
30+
"author_name", // 3
31+
"text", // 4
32+
"thumb_url", // 5
33+
"color", // 6
34+
"title_link", // 7
35+
"title_link_download", // 8
36+
"image_url", // 9
37+
"image_type", // 10
38+
"image_size", // 11
39+
"video_url", // 12
40+
"video_type", // 13
41+
"video_size", // 14
42+
"audio_url", // 15
43+
"audio_type", // 16
44+
"audio_size", // 17
45+
"message_link", // 18
46+
"attachments", // 19
47+
"ts", // 20
48+
"author_icon", // 21
49+
"author_link", // 22
50+
"image_preview", // 23
51+
"fields", // 24
52+
"fallback", // 25
53+
"button_alignment", // 26
54+
"actions" // 27
5555
)
5656

5757
private val OPTIONS = JsonReader.Options.of(*NAMES)
@@ -61,34 +61,34 @@ class AttachmentAdapter(moshi: Moshi, private val logger: Logger) : JsonAdapter<
6161
return reader.nextNull<Attachment>()
6262
}
6363

64-
var title: String? = null // 0
65-
var type: String? = null // 1
66-
var description: String? = null // 2
67-
var authorName: String? = null // 3
68-
var text: String? = null // 4
69-
var thumbUrl: String? = null // 5
70-
var color: Color? = null // 6
71-
var titleLink: String? = null // 7
72-
var titleLinkDownload = false // 8
73-
var imageUrl: String? = null // 9
74-
var imageType: String? = null // 10
75-
var imageSize: Long? = null // 11
76-
var videoUrl: String? = null // 12
77-
var videoType: String? = null // 13
78-
var videoSize: Long? = null // 14
79-
var audioUrl: String? = null // 15
80-
var audioType: String? = null // 16
81-
var audioSize: Long? = null // 17
82-
var messageLink: String? = null // 18
64+
var title: String? = null // 0
65+
var type: String? = null // 1
66+
var description: String? = null // 2
67+
var authorName: String? = null // 3
68+
var text: String? = null // 4
69+
var thumbUrl: String? = null // 5
70+
var color: Color? = null // 6
71+
var titleLink: String? = null // 7
72+
var titleLinkDownload = false // 8
73+
var imageUrl: String? = null // 9
74+
var imageType: String? = null // 10
75+
var imageSize: Long? = null // 11
76+
var videoUrl: String? = null // 12
77+
var videoType: String? = null // 13
78+
var videoSize: Long? = null // 14
79+
var audioUrl: String? = null // 15
80+
var audioType: String? = null // 16
81+
var audioSize: Long? = null // 17
82+
var messageLink: String? = null // 18
8383
var attachments: List<Attachment>? = null // 19
84-
var timestamp: Long? = null // 20
85-
var authorIcon: String? = null // 21
86-
var authorLink: String? = null // 22
87-
var imagePreview: String? = null // 23
88-
var fields: List<Field>? = null // 24
89-
var fallback: String? = null // 25
90-
var buttonAlignment: String? = null // 26
91-
var actions: List<Action>? = null // 27
84+
var timestamp: Long? = null // 20
85+
var authorIcon: String? = null // 21
86+
var authorLink: String? = null // 22
87+
var imagePreview: String? = null // 23
88+
var fields: List<Field>? = null // 24
89+
var fallback: String? = null // 25
90+
var buttonAlignment: String? = null // 26
91+
var actions: List<Action>? = null // 27
9292

9393
reader.beginObject()
9494
while (reader.hasNext()) {

core/src/main/kotlin/chat/rocket/core/internal/RoomListAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal class RoomListAdapter(moshi: Moshi, private val logger: Logger) : JsonA
2424
private val adapter = moshi.adapter<Room>(Room::class.java)
2525

2626
override fun toJson(writer: JsonWriter, value: List<Room>?) {
27-
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
27+
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
2828
}
2929

3030
override fun fromJson(reader: JsonReader): List<Room>? {

0 commit comments

Comments
 (0)