正在显示
5 个修改的文件
包含
33 行增加
和
6 行删除
| @@ -609,6 +609,10 @@ internal constructor( | @@ -609,6 +609,10 @@ internal constructor( | ||
| 609 | listener?.onSubscriptionPermissionUpdate(subscriptionPermissionUpdate) | 609 | listener?.onSubscriptionPermissionUpdate(subscriptionPermissionUpdate) |
| 610 | } | 610 | } |
| 611 | 611 | ||
| 612 | + override fun onRefreshToken(token: String) { | ||
| 613 | + sessionToken = token | ||
| 614 | + } | ||
| 615 | + | ||
| 612 | //--------------------------------- DataChannel.Observer ------------------------------------// | 616 | //--------------------------------- DataChannel.Observer ------------------------------------// |
| 613 | 617 | ||
| 614 | override fun onBufferedAmountChange(previousAmount: Long) { | 618 | override fun onBufferedAmountChange(previousAmount: Long) { |
| @@ -92,7 +92,7 @@ constructor( | @@ -92,7 +92,7 @@ constructor( | ||
| 92 | ): Either<LivekitRtc.JoinResponse, Unit> { | 92 | ): Either<LivekitRtc.JoinResponse, Unit> { |
| 93 | var wsUrlString = "$url/rtc" + | 93 | var wsUrlString = "$url/rtc" + |
| 94 | "?protocol=$PROTOCOL_VERSION" + | 94 | "?protocol=$PROTOCOL_VERSION" + |
| 95 | - "&access_token=$token" + | 95 | + "&$CONNECT_QUERY_TOKEN=$token" + |
| 96 | "&sdk=$SDK_TYPE" + | 96 | "&sdk=$SDK_TYPE" + |
| 97 | "&version=${Version.CLIENT_VERSION}" | 97 | "&version=${Version.CLIENT_VERSION}" |
| 98 | isReconnecting = false | 98 | isReconnecting = false |
| @@ -339,12 +339,12 @@ constructor( | @@ -339,12 +339,12 @@ constructor( | ||
| 339 | allParticipants: Boolean, | 339 | allParticipants: Boolean, |
| 340 | participantTrackPermissions: List<ParticipantTrackPermission> | 340 | participantTrackPermissions: List<ParticipantTrackPermission> |
| 341 | ) { | 341 | ) { |
| 342 | - val update = LivekitRtc.UpdateSubscriptionPermissions.newBuilder() | 342 | + val update = LivekitRtc.SubscriptionPermission.newBuilder() |
| 343 | .setAllParticipants(allParticipants) | 343 | .setAllParticipants(allParticipants) |
| 344 | .addAllTrackPermissions(participantTrackPermissions.map { it.toProto() }) | 344 | .addAllTrackPermissions(participantTrackPermissions.map { it.toProto() }) |
| 345 | 345 | ||
| 346 | val request = LivekitRtc.SignalRequest.newBuilder() | 346 | val request = LivekitRtc.SignalRequest.newBuilder() |
| 347 | - .setSubscriptionPermissions(update) | 347 | + .setSubscriptionPermission(update) |
| 348 | .build() | 348 | .build() |
| 349 | 349 | ||
| 350 | sendRequest(request) | 350 | sendRequest(request) |
| @@ -473,6 +473,9 @@ constructor( | @@ -473,6 +473,9 @@ constructor( | ||
| 473 | LivekitRtc.SignalResponse.MessageCase.SUBSCRIPTION_PERMISSION_UPDATE -> { | 473 | LivekitRtc.SignalResponse.MessageCase.SUBSCRIPTION_PERMISSION_UPDATE -> { |
| 474 | listener?.onSubscriptionPermissionUpdate(response.subscriptionPermissionUpdate) | 474 | listener?.onSubscriptionPermissionUpdate(response.subscriptionPermissionUpdate) |
| 475 | } | 475 | } |
| 476 | + LivekitRtc.SignalResponse.MessageCase.REFRESH_TOKEN -> { | ||
| 477 | + listener?.onRefreshToken(response.refreshToken) | ||
| 478 | + } | ||
| 476 | LivekitRtc.SignalResponse.MessageCase.MESSAGE_NOT_SET, | 479 | LivekitRtc.SignalResponse.MessageCase.MESSAGE_NOT_SET, |
| 477 | null -> { | 480 | null -> { |
| 478 | LKLog.v { "empty messageCase!" } | 481 | LKLog.v { "empty messageCase!" } |
| @@ -507,9 +510,12 @@ constructor( | @@ -507,9 +510,12 @@ constructor( | ||
| 507 | fun onStreamStateUpdate(streamStates: List<LivekitRtc.StreamStateInfo>) | 510 | fun onStreamStateUpdate(streamStates: List<LivekitRtc.StreamStateInfo>) |
| 508 | fun onSubscribedQualityUpdate(subscribedQualityUpdate: LivekitRtc.SubscribedQualityUpdate) | 511 | fun onSubscribedQualityUpdate(subscribedQualityUpdate: LivekitRtc.SubscribedQualityUpdate) |
| 509 | fun onSubscriptionPermissionUpdate(subscriptionPermissionUpdate: LivekitRtc.SubscriptionPermissionUpdate) | 512 | fun onSubscriptionPermissionUpdate(subscriptionPermissionUpdate: LivekitRtc.SubscriptionPermissionUpdate) |
| 513 | + fun onRefreshToken(token: String) | ||
| 510 | } | 514 | } |
| 511 | 515 | ||
| 512 | companion object { | 516 | companion object { |
| 517 | + const val CONNECT_QUERY_TOKEN = "access_token" | ||
| 518 | + | ||
| 513 | const val SD_TYPE_ANSWER = "answer" | 519 | const val SD_TYPE_ANSWER = "answer" |
| 514 | const val SD_TYPE_OFFER = "offer" | 520 | const val SD_TYPE_OFFER = "offer" |
| 515 | const val SD_TYPE_PRANSWER = "pranswer" | 521 | const val SD_TYPE_PRANSWER = "pranswer" |
| @@ -3,13 +3,12 @@ package io.livekit.android.room | @@ -3,13 +3,12 @@ package io.livekit.android.room | ||
| 3 | import io.livekit.android.MockE2ETest | 3 | import io.livekit.android.MockE2ETest |
| 4 | import io.livekit.android.mock.MockPeerConnection | 4 | import io.livekit.android.mock.MockPeerConnection |
| 5 | import io.livekit.android.mock.MockWebSocket | 5 | import io.livekit.android.mock.MockWebSocket |
| 6 | -import io.livekit.android.util.LoggingRule | 6 | +import io.livekit.android.util.toOkioByteString |
| 7 | import io.livekit.android.util.toPBByteString | 7 | import io.livekit.android.util.toPBByteString |
| 8 | import kotlinx.coroutines.ExperimentalCoroutinesApi | 8 | import kotlinx.coroutines.ExperimentalCoroutinesApi |
| 9 | import livekit.LivekitRtc | 9 | import livekit.LivekitRtc |
| 10 | import org.junit.Assert | 10 | import org.junit.Assert |
| 11 | import org.junit.Before | 11 | import org.junit.Before |
| 12 | -import org.junit.Rule | ||
| 13 | import org.junit.Test | 12 | import org.junit.Test |
| 14 | import org.junit.runner.RunWith | 13 | import org.junit.runner.RunWith |
| 15 | import org.robolectric.RobolectricTestRunner | 14 | import org.robolectric.RobolectricTestRunner |
| @@ -56,4 +55,17 @@ class RTCEngineMockE2ETest : MockE2ETest() { | @@ -56,4 +55,17 @@ class RTCEngineMockE2ETest : MockE2ETest() { | ||
| 56 | val newWs = wsFactory.ws | 55 | val newWs = wsFactory.ws |
| 57 | Assert.assertNotEquals(oldWs, newWs) | 56 | Assert.assertNotEquals(oldWs, newWs) |
| 58 | } | 57 | } |
| 58 | + | ||
| 59 | + @Test | ||
| 60 | + fun refreshToken() = runTest { | ||
| 61 | + connect() | ||
| 62 | + | ||
| 63 | + val oldToken = wsFactory.request.url.queryParameter(SignalClient.CONNECT_QUERY_TOKEN) | ||
| 64 | + wsFactory.listener.onMessage(wsFactory.ws, SignalClientTest.REFRESH_TOKEN.toOkioByteString()) | ||
| 65 | + wsFactory.listener.onFailure(wsFactory.ws, Exception(), null) | ||
| 66 | + | ||
| 67 | + val newToken = wsFactory.request.url.queryParameter(SignalClient.CONNECT_QUERY_TOKEN) | ||
| 68 | + Assert.assertNotEquals(oldToken, newToken) | ||
| 69 | + Assert.assertEquals(SignalClientTest.REFRESH_TOKEN.refreshToken, newToken) | ||
| 70 | + } | ||
| 59 | } | 71 | } |
| @@ -275,6 +275,11 @@ class SignalClientTest : BaseTest() { | @@ -275,6 +275,11 @@ class SignalClientTest : BaseTest() { | ||
| 275 | } | 275 | } |
| 276 | build() | 276 | build() |
| 277 | } | 277 | } |
| 278 | + | ||
| 279 | + val REFRESH_TOKEN = with(LivekitRtc.SignalResponse.newBuilder()) { | ||
| 280 | + refreshToken = "refresh_token" | ||
| 281 | + build() | ||
| 282 | + } | ||
| 278 | val LEAVE = with(LivekitRtc.SignalResponse.newBuilder()) { | 283 | val LEAVE = with(LivekitRtc.SignalResponse.newBuilder()) { |
| 279 | leave = with(leaveBuilder) { | 284 | leave = with(leaveBuilder) { |
| 280 | build() | 285 | build() |
-
请 注册 或 登录 后发表评论