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
2024-08-06 17:22:16 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-08-06 17:22:16 +0900
Commit
139869fe0549ac9d7e09e6cd1980a1430e5f21ba
139869fe
1 parent
625022f3
Support setting attributes from local participant (#470)
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
34 行增加
和
0 行删除
livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt
livekit-android-test/src/main/java/io/livekit/android/test/mock/TestData.kt
livekit-android-test/src/test/java/io/livekit/android/room/participant/LocalParticipantMockE2ETest.kt
livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt
查看文件 @
139869f
...
...
@@ -718,6 +718,19 @@ internal constructor(
this.engine.client.sendUpdateLocalMetadata(metadata, name)
}
/**
* Set or update participant attributes. It will make updates only to keys that
* are present in [attributes], and will not override others.
*
* To delete a value, set the value to an empty string.
*
* Note: this requires `canUpdateOwnMetadata` permission.
* @param attributes attributes to update
*/
fun updateAttributes(attributes: Map<String, String>) {
this.engine.client.sendUpdateLocalMetadata(metadata, name, attributes)
}
internal fun onRemoteMuteChanged(trackSid: String, muted: Boolean) {
val pub = trackPublications[trackSid]
pub?.muted = muted
...
...
livekit-android-test/src/main/java/io/livekit/android/test/mock/TestData.kt
查看文件 @
139869f
...
...
@@ -62,6 +62,7 @@ object TestData {
.setHidden(true)
.setRecorder(false)
.build()
putAttributes("attribute", "value")
build()
}
...
...
@@ -79,6 +80,7 @@ object TestData {
}
addTracks(REMOTE_AUDIO_TRACK)
addTracks(REMOTE_VIDEO_TRACK)
putAttributes("attribute", "value")
build()
}
...
...
@@ -225,6 +227,7 @@ object TestData {
val participantMetadataChanged = LOCAL_PARTICIPANT.toBuilder()
.setMetadata("changed_metadata")
.setName("changed_name")
.putAttributes("attribute", "changed_value")
.build()
addParticipants(participantMetadataChanged)
...
...
livekit-android-test/src/test/java/io/livekit/android/room/participant/LocalParticipantMockE2ETest.kt
查看文件 @
139869f
...
...
@@ -152,6 +152,23 @@ class LocalParticipantMockE2ETest : MockE2ETest() {
}
@Test
fun updateAttributes() = runTest {
connect()
wsFactory.ws.clearRequests()
val newAttributes = mapOf("attribute" to "changedValue")
room.localParticipant.updateAttributes(newAttributes)
val requestString = wsFactory.ws.sentRequests.first().toPBByteString()
val sentRequest = LivekitRtc.SignalRequest.newBuilder()
.mergeFrom(requestString)
.build()
assertTrue(sentRequest.hasUpdateMetadata())
assertEquals(newAttributes, sentRequest.updateMetadata.attributesMap)
}
@Test
fun participantMetadataChanged() = runTest {
connect()
...
...
@@ -183,6 +200,7 @@ class LocalParticipantMockE2ETest : MockE2ETest() {
listOf(
ParticipantEvent.MetadataChanged::class.java,
ParticipantEvent.NameChanged::class.java,
ParticipantEvent.AttributesChanged::class.java,
),
participantEvents,
)
...
...
请
注册
或
登录
后发表评论