Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
livekitAndroidXuningTest
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
davidliu
2023-05-18 01:04:06 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2023-05-18 01:04:06 +0900
Commit
def38bd3327d1cdd762c3dbdbb67b7b8e521ebf6
def38bd3
1 parent
1a39a7bf
Add lastSpokeAt and joinedAt fields to Participant (#226)
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
40 行增加
和
6 行删除
livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Participant.kt
livekit-android-sdk/src/test/java/io/livekit/android/room/participant/ParticipantTest.kt
protocol
livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Participant.kt
查看文件 @
def38bd
...
...
@@ -14,6 +14,7 @@ import io.livekit.android.util.flowDelegate
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import livekit.LivekitModels
import java.util.Date
import javax.inject.Named
open class Participant(
...
...
@@ -69,6 +70,9 @@ open class Participant(
listener?.onSpeakingChanged(this)
internalListener?.onSpeakingChanged(this)
eventBus.postEvent(ParticipantEvent.SpeakingChanged(this, newValue), scope)
if (newValue) {
lastSpokeAt = Date().time
}
}
}
internal set
...
...
@@ -124,6 +128,20 @@ open class Participant(
internal set
/**
* Timestamp when participant joined room, in milliseconds
*/
val joinedAt
get() = participantInfo?.joinedAt?.times(1000)
/**
* Timestamp when the participant last started speaking, in milliseconds
*/
@FlowObservable
@get:FlowObservable
var lastSpokeAt by flowDelegate<Long?>(null)
internal set
/**
* Listener for when participant properties change
*/
@Deprecated("Use events instead")
...
...
livekit-android-sdk/src/test/java/io/livekit/android/room/participant/ParticipantTest.kt
查看文件 @
def38bd
...
...
@@ -9,10 +9,14 @@ import kotlinx.coroutines.test.runTest
import livekit.LivekitModels
import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import java.util.Date
import kotlin.math.abs
@ExperimentalCoroutinesApi
class ParticipantTest {
...
...
@@ -125,15 +129,27 @@ class ParticipantTest {
participant.dispose()
assertEquals("", participant.sid)
Assert.assertNull(participant.name)
Assert.assertNull(participant.identity)
Assert.assertNull(participant.metadata)
Assert.assertNull(participant.permissions)
Assert.assertNull(participant.participantInfo)
assertNull(participant.name)
assertNull(participant.identity)
assertNull(participant.metadata)
assertNull(participant.permissions)
assertNull(participant.participantInfo)
Assert.assertFalse(participant.isSpeaking)
assertEquals(ConnectionQuality.UNKNOWN, participant.connectionQuality)
}
@Test
fun speakingUpdatesLastSpokeAt() = runTest {
assertNull(participant.lastSpokeAt)
participant.isSpeaking = true
val lastSpokeAt = participant.lastSpokeAt
val timestamp = Date().time
assertNotNull(lastSpokeAt)
assertTrue(abs(lastSpokeAt!! - timestamp) < 1000)
}
companion object {
val INFO = LivekitModels.ParticipantInfo.newBuilder()
.setSid("sid")
...
...
protocol
@
ac74d1e9
Subproject commit
e78c5b18c0f3a18bae5d5cec44d30bb6358b9bc4
Subproject commit
ac74d1e920384ac3972b6017d1514ca983450f0d
...
...
请
注册
或
登录
后发表评论