Committed by
GitHub
set permission by identity (#91)
* update protocol repo * Permission by identity
正在显示
3 个修改的文件
包含
42 行增加
和
3 行删除
| @@ -650,22 +650,34 @@ data class AudioTrackPublishOptions( | @@ -650,22 +650,34 @@ data class AudioTrackPublishOptions( | ||
| 650 | 650 | ||
| 651 | data class ParticipantTrackPermission( | 651 | data class ParticipantTrackPermission( |
| 652 | /** | 652 | /** |
| 653 | + * The participant identity this permission applies to. | ||
| 654 | + * You can either provide this or `participantSid` | ||
| 655 | + */ | ||
| 656 | + val participantIdentity: String? = null, | ||
| 657 | + /** | ||
| 653 | * The participant id this permission applies to. | 658 | * The participant id this permission applies to. |
| 654 | */ | 659 | */ |
| 655 | - val participantSid: String, | 660 | + val participantSid: String? = null, |
| 656 | /** | 661 | /** |
| 657 | * If set to true, the target participant can subscribe to all tracks from the local participant. | 662 | * If set to true, the target participant can subscribe to all tracks from the local participant. |
| 658 | * | 663 | * |
| 659 | * Takes precedence over [allowedTrackSids]. | 664 | * Takes precedence over [allowedTrackSids]. |
| 660 | */ | 665 | */ |
| 661 | - val allTracksAllowed: Boolean, | 666 | + val allTracksAllowed: Boolean = false, |
| 662 | /** | 667 | /** |
| 663 | * The list of track ids that the target participant can subscribe to. | 668 | * The list of track ids that the target participant can subscribe to. |
| 664 | */ | 669 | */ |
| 665 | val allowedTrackSids: List<String> = emptyList() | 670 | val allowedTrackSids: List<String> = emptyList() |
| 666 | ) { | 671 | ) { |
| 672 | + init { | ||
| 673 | + if (participantIdentity == null && participantSid == null) { | ||
| 674 | + throw IllegalArgumentException("Either identity or sid must be provided.") | ||
| 675 | + } | ||
| 676 | + } | ||
| 677 | + | ||
| 667 | fun toProto(): LivekitRtc.TrackPermission { | 678 | fun toProto(): LivekitRtc.TrackPermission { |
| 668 | return LivekitRtc.TrackPermission.newBuilder() | 679 | return LivekitRtc.TrackPermission.newBuilder() |
| 680 | + .setParticipantIdentity(participantIdentity) | ||
| 669 | .setParticipantSid(participantSid) | 681 | .setParticipantSid(participantSid) |
| 670 | .setAllTracks(allTracksAllowed) | 682 | .setAllTracks(allTracksAllowed) |
| 671 | .addAllTrackSids(allowedTrackSids) | 683 | .addAllTrackSids(allowedTrackSids) |
| 1 | +package io.livekit.android.room.participant | ||
| 2 | + | ||
| 3 | +import org.junit.Test | ||
| 4 | + | ||
| 5 | +class ParticipantTrackPermissionTest { | ||
| 6 | + @Test(expected = IllegalArgumentException::class) | ||
| 7 | + fun requireSidOrIdentity() { | ||
| 8 | + ParticipantTrackPermission( | ||
| 9 | + participantIdentity = null, | ||
| 10 | + participantSid = null | ||
| 11 | + ) | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + @Test | ||
| 15 | + fun sidConstructionDoesntThrow() { | ||
| 16 | + ParticipantTrackPermission( | ||
| 17 | + participantSid = "sid" | ||
| 18 | + ) | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + @Test | ||
| 22 | + fun identyConstructionDoesntThrow() { | ||
| 23 | + ParticipantTrackPermission( | ||
| 24 | + participantIdentity = "identity" | ||
| 25 | + ) | ||
| 26 | + } | ||
| 27 | +} |
-
请 注册 或 登录 后发表评论